perm filename MACSYM.HPM[UP,DOC]7 blob
sn#150501 filedate 1975-03-18 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00145 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00006 00002
C00007 00003
C00008 00004
C00010 00005
C00013 00006
C00015 00007 ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
C00019 00008
C00023 00009
C00028 00010
C00029 00011
C00033 00012
C00037 00013
C00041 00014
C00044 00015
C00049 00016
C00052 00017
C00055 00018
C00059 00019
C00062 00020
C00065 00021
C00068 00022
C00072 00023
C00076 00024
C00081 00025
C00084 00026
C00088 00027
C00090 00028
C00095 00029
C00100 00030
C00105 00031
C00109 00032
C00111 00033
C00114 00034
C00119 00035
C00124 00036
C00127 00037
C00132 00038
C00135 00039
C00137 00040
C00142 00041
C00145 00042
C00148 00043
C00152 00044
C00155 00045
C00158 00046
C00161 00047
C00165 00048
C00169 00049
C00173 00050
C00177 00051
C00181 00052
C00185 00053
C00188 00054
C00192 00055
C00197 00056
C00201 00057
C00205 00058
C00208 00059
C00211 00060
C00214 00061
C00217 00062
C00220 00063
C00224 00064
C00228 00065
C00232 00066
C00234 00067
C00237 00068
C00241 00069
C00244 00070
C00248 00071
C00251 00072
C00255 00073
C00259 00074
C00262 00075
C00266 00076
C00269 00077
C00272 00078
C00274 00079
C00279 00080
C00283 00081
C00287 00082
C00291 00083
C00292 00084
C00295 00085
C00297 00086
C00301 00087
C00305 00088
C00310 00089
C00315 00090
C00317 00091
C00319 00092
C00324 00093
C00328 00094
C00333 00095
C00337 00096
C00342 00097
C00347 00098
C00351 00099
C00355 00100
C00356 00101
C00361 00102
C00365 00103
C00366 00104
C00371 00105
C00374 00106
C00379 00107
C00383 00108
C00387 00109
C00389 00110
C00394 00111
C00399 00112
C00403 00113
C00408 00114
C00413 00115
C00418 00116
C00423 00117
C00428 00118
C00429 00119
C00433 00120
C00436 00121
C00440 00122
C00445 00123
C00450 00124
C00454 00125 βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
C00458 00126
C00460 00127
C00461 00128
C00464 00129
C00466 00130
C00468 00131
C00470 00132 βββββββββββββββββ
C00474 00133
C00475 00134
C00479 00135
C00483 00136
C00487 00137
C00491 00138
C00495 00139
C00499 00140
C00503 00141
C00506 00142 β
C00509 00143
C00512 00144
C00514 00145 ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
C00515 ENDMK
C⊗;
JUNE 1973
M A C S Y M A R E F E R E N C E M A N U A L
BY
THE MATHLAB GROUP
PROJECT MAC - M.I.T.
CAMBRIDGE, MASSACHUSETTS
VERSION FIVE
Work reported herein was supported in part by Project MAC, an
M. I. T. interdepartmental laboratory sponsored by the Advanced
Research Projects Agency (ARPA), Department of Defense, under
Office of Naval Research Contract N00014-70-A-0362-0001.
Copyright (c) 1973 by Massachusetts Institute of Technology
Cambridge, Massachusetts 02139
Preface
This manual is constantly undergoing revision as new
features are added to MACSYMA. Currently it corresponds to
MACSYMA version --- which has approximately 126,000 words of
code. Any comments, suggestions, or criticisms are welcome and
should be addressed to:
Richard A. Bogen - Room 832
Project MAC
545 Technology Square
Cambridge, Mass. 02139
Acknowledgements
This manual was written by Richard Bogen with the assis-
tance of Jeffrey Golden. Specific sections were contributed by
Jeffrey Golden and Eric Rosen. In addition many suggestions
were received from Martin Cole, Richard Fateman, and Joel Moses.
Note
Current members of the Mathlab group are Richard A. Bogen,
Richard J. Fateman, Michael R. Genesereth, Jeffrey P. Golden,
Stavros M. Macrakis, William A. Martin, Joel Moses, Vera Pless,
Eric C. Rosen, Richard Schroeppel, Guy L. Steele Jr., Barry M.
Trager, Paul S. Wang, Jon L. White, David Y. Y. Yun, and Richard
E. Zippel.
Table of Contents
1.0 Introduction
2.0 Using MACSYMA
2.1 Logging In and Out
2.2 Levels of Control
2.3 General Information
3.0 Data Types and Statement Types
3.1 Numbers
3.2 Names
3.3 Quoted Strings
3.4 Names and Assignment
3.5 Mathematical Operators
3.6 Functions and Arrays
3.6.1 Functions
3.6.2 Arrays
3.6.3 Arrays of Functions
3.7 Lists
3.8 Matrices
3.9 Equations
3.10 IF Statement
3.11 Program Blocks
3.12 DO Statement
3.12.1 Commonly Used Form
3.12.2 Additional Features
4.0 Representation, Evaluation, and Simplification
5.0 Miscellaneous Hints and Facilities
6.0 Predefined Mathematical Constants and Functions
7.0 MACSYMA Functions and Variables
7.1 General Purpose Commands
7.2 Part Selection and Substitution Commands
7.3 SOLVE and Related Commands
7.4 Matrix Commands
7.5 Other General Purpose Commands
7.6 Rational Function Commands
7.6.1 Extended Rational Function Commands
7.7 Type Testing Commands
7.8 Pattern Matching and Related Commands
7.9 Graphing Commands
7.10 Utility, Input-Output, and Display Commands
7.11 List Handling and LISP-like Commands
7.12 Compare Commands
7.13 Debugging Commands
8.0 The MACSYMA Editor
8.1 Introduction
8.2 Entering the Editor
8.3 Description of the Commands
9.0 The Batch Commands
9.1 Introduction
9.2 The Simple Format
9.3 The More Complicated Format
9.4 The BATCON Command
9.5 Miscellany
10.0 The Secondary Storage Commands
10.1 Introduction
10.2 Automatic Storage of Expressions
10.3 Explicit Storage
10.4 Saving a MACSYMA Overnight
11.0 The Plotting Commands
12.0 Debugging in MACSYMA
Bibliography and References
Appendix I - MACSYMA's Grammar
Appendix II - Illustrative Examples
Index I - Forms and Concepts
Index II - Commands
Index III - Constants and Variables
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Introduction page 1-1
1.0 Introduction
MACSYMA (Project MAC's SYmbolic MAnipulation System) is a
large computer program developed by the Mathlab group of Project
MAC's Automatic Programming Division. It is written in LISP
[19, 30] and runs under the ITS time sharing system [8] (developed
at the MIT Artifical Intelligence Laboratory) on a DEC PDP-10
computer at Project MAC, MIT. MACSYMA has capabilities for manip-
ulating algebraic expressions involving constants, variables, and
functions. One can differentiate, integrate, take limits, solve
equations, factor polynomials, expand functions in power series,
plot curves, etc. In addition there are facilities for manipu-
lating lists, subscripted variables, equations, and matrices with
many of the usual operations on them being available. The user
can also create his own functions and he can extend existing
functions and operators.
This manual is intended to be a complete reference to MACSYMA
features as of the date shown. (New features under development
are, for the most part, not mentioned.)
We do not pretend to discuss all of the issues involved in
the efficient manipulation of algebraic expressions nor is this
manual intended to be a tutorial. The novice may benefit from
reading the MACSYMA primer [24] first.
The next section gives a brief introduction to the
time-sharing system on which MACSYMA runs. For further details
the reader should consult [7, 8, 25].
Using MACSYMA page 2-1
2.0 Using MACSYMA
2.1 Logging in and out
In order to use MACSYMA a user must have access to the
MATHLAB PDP-10 computer at MIT by (1) finding a terminal connected
to it or (2) finding one on which he can dial to it over public
telephone lines or (3) logging into it over the ARPA network.
Once this is done the user should be communicating with the ITS
time sharing system. To login he should type a control-Z (while
depressing the control key type the letter Z) which loads in DDT
[25] (the top level system program). Then he should type :LOGIN
followed by a space and his user name. (All system commands, i.e.
those which begin with a colon, are terminated by a carriage
return). At this point the user can start up any of several
system programs available (PEEK [8], TECO [7], etc.) by typing a :
followed by the name of the program. In particular :MACSYM loads
in and begins execution of MACSYMA. After printing some
descriptive information, including the version number, MACSYMA
prints (C1) which means that it is ready to accept input from the
user. The entire sequence is shown below with the computer's
output indented. ↑| means the control key is to be held down
while the next character is typed. --- represents a version
number which changes from time to time.
ML ITS --- CONSOLE -- FREE
↑|Z (not printed on console)
ML ITS ---.DDT.---.
:LOGIN SMITH
:MACSYM
THIS IS MACSYMA ---
(C1) NROOTS(2*X**5-X+5,-4,8);
(D1) 1
↑|Z
.IOT 1,1
:LOGOUT
ML ITS --- CONSOLE -- FREE
In line (C1) the user has typed a command which asks for the
number of realroots between -4 and 8 of a quintic polynomial. In
line (D1) MACSYMA has printed the answer. The ↑|Z causes an exit
from MACSYMA to DDT after which the system typed .IOT 1,1 (meaning
that MACSYMA was waiting for input). Typing :LOGOUT causes the
system to delete all the user's jobs (in this case MACSYMA was the
only job) and to log him out of ITS. When the user finishes he
Using MACSYMA page 2-2
should always log the console out before he leaves.
2.2 Levels of Control
Typing :MACSYM causes a LISP system extended with MACSYMA
programs to be loaded into main memory from auxiliary storage and
the top level MACSYMA program (called SUPERVISOR) to be given
control. SUPERVISOR invokes other programs which read in,
evaluate, simplify, and display the user's expressions. All of
the commands to be presented in subsequent sections are actually
LISP programs which, when they are called, may invoke many other
LISP programs in a process that is invisible to the user.
Switching between DDT, MACSYMA, and the LISP system in which
it is embedded is accomplished by typing the following characters:
↑|G typed while in MACSYMA causes LISP to be entered. The
user can now type any LISP S-expression and have it
evaluated. Typing (CONTINUE) causes MACSYMA to be
re-entered. (i.e. MACSYMA's supervisor is given control).
↑|Z causes an immediate exit to DDT. At this point the user
can run some other program like PEEK or TECO [7]. When in
DDT, typing :CONTINUE causes the current job to be resumed.
(:JOB MACSYM should be typed first if the user wishes to
re-enter a MACSYMA which is not the current job).
2.3 General Information
Commands to MACSYMA are strings of characters representing
mathematical expressions, equations, arrays, functions, and pro-
grams. Extra spaces, tabs, and all carriage returns are ignored
(except when these occur in quoted strings).
Commands are terminated by ; or $. A ; causes the command to
be evaluated and the result displayed. The terminator $ differs
in that the display of the result is suppressed.
When typing commands, depressing the "rubout" or "delete" key
deletes (and echoes back at the console) the previous character.
The two characters ?? delete the whole command, and cause the line
number to be redisplayed.
Lines are consecutively numbered, except that the input line
(Ci) will be followed by an output line (which may or may not be
displayed) named (Di). The next input-output pair will be
labelled (C[i+1]) and (D[i+1]), respectively. The most recently
computed expression may be referred to as %.
If one command produces several intermediate lines of output,
the labels will begin with an E, and the line number will be
incremented by one for each additional line.
Any command or expression can be referred to by its line
Using MACSYMA page 2-3
label. The use of C, D, and E as labels can be changed by the
user if desired by resetting the values of certain variables
(refer to section 7.10).
If the input line contains a syntax error, it will be
reprinted and the location of the error will be indicated by
***$***.
Data and Statement Types page 3-1
3.0 MACSYMA's Data Types and Statement Types
This section describes the kinds of expressions MACSYMA
permits and their meanings. Sections 6.0 and 7.0 should be
referred to where necessary in order to clarify the examples
presented.
3.1 Numbers
Numbers are either integers, rational numbers, or floating
point numbers. Integers consist of a string of digits not
containing a period, rational numbers are the quotient of two
integers and are written as numerator/denominator, and floating
point numbers are written as in FORTRAN, i.e. strings of digits
containing a period and optionally followed by an integer exponent
beginning with the letter E. Negative numbers begin with a minus
sign. There is no limit on the number of digits in an integer or
rational number but non-zero floating point numbers must have
absolute value between .14E-38 and 1.7E38 and are limited to
approximately 8 digits precision (PDP-10 limitations). (An
arbitrary precision floating point evaluation subsystem will be
available shortly which will remove the restrictions from floating
point numbers. Interval arithmetic will also become available at
that time).
-17253733574534 6.023E23 -1.6E-19
3.14159 227 -3354665557334/66724255465544
3.2 Names
Names are used to designate variables, functions, and arrays.
A name consists of a string of letters (including %) and digits.
It may also include other characters but these must be preceded
with a \. Names can be of any length and must begin with a letter
(unless the leading character is a \).
Lower case letters may be typed, but they are immediately
converted into the corresponding upper case letters (unless
BOTHCASES(TRUE) has been executed. see 7.10).
%PI EPSILON X10Y30ISASTRANGENAME \*SPECIAL
3.3 Quoted Strings
A string of characters of any length may be constructed by
enclosing the string in "s. To include a " or a ; or $ in the
string it is necessary to precede it with a \. Quoted strings are
Data and Statement Types page 3-2
useful in printing messages (such as those giving instructions for
inputting data) or in printing descriptive titles for outputted
data.
(C1) PRINT("IS X POSITIVE ?")$
IS X POSITIVE ?
3.4 Names and Assignment
Names used as variables (rather than as functions or arrays)
are assigned values by writing the name of the variable followed
by a : followed by an expression representing the value to be
assigned to the variable. A name can be assigned a new value at
any time. The value of a variable can be a number, a matrix, a
list, or any other MACSYMA expression.
(Certain names may only be used if surrounded by "s because
they normally serve as keywords to the parsing program. These
words are given in the appendix.)
Some simple examples of assignment follow. (The comments in
parentheses are only for the reader's benefit and are not actually
typed to or by MACSYMA.)
line numbers expressions comments
(C1) A:16$ (integer)
(C2) LAMBDA: -3/37$ (rational number)
(C3) X:D1; (X is assigned the value of D1)
(D3) 16
(Note that every input expression Ci produces an output expression
Di whether it is displayed or not).
(C4) RHO:SIGMA; (since SIGMA has no value at this time
RHO is assigned the symbol SIGMA)
(D4) SIGMA
(C5) SIGMA: .005$ (floating point)
(C6) RHO; (RHO still has its old value
(D6) SIGMA since it hasn't been reassigned
a new one)
The MACSYMA variable VALUES is a list (sect. 3.7) of all the
user's variables which are bound (i.e. have been assigned values)
up to the time VALUES is referenced.
The special assignment operator :: assigns the value of the
expression on its right to the value of the quantity on its left,
which must evaluate to a simple variable or array element (sect.
3.6.2). Thus continuing with the above examples:
Data and Statement Types page 3-3
(C7) RHO::LAMBDA$ (Note that the :: causes the value of
(C8) SIGMA; LAMBDA, i.e. -3/37, to be assigned to
(D8) -3/37 the value of RHO, i.e. SIGMA.)
(C9) VALUES;
(D9) [A, LAMBDA, X, RHO, SIGMA]
3.5 Mathematical Operators
Mathematical expressions are constructed by using the
following operators and also functional application. The usage
and priorities from highest to lowest are:
Operator Name Symbol Usage
factorial !! ! postfix
exponentiation ** ↑ infix
non-commutative ↑↑ infix
exponentiation
negation - prefix
non-commutative . infix
multiplication
div'sn mult'pn / * infix
add'n subt'n + - infix
!! stands for double factorial which is defined as the
product of all the consecutive odd (or even) numbers from 1 (or 2)
to the odd (or even) argument. Thus 8!! is 2*4*6*8.
Period is used for non-commutative product. It must be
preceded and followed by a space when any ambiguity can arise with
respect to floating point numbers. M.M is the same as M↑↑2.
Operators of equal priority are performed left to right.
Parentheses can be used to change the order of evaluation. Also
functional application has the highest priority. Thus
SIN(A*X**Y/Z!)**2 means (SIN(A*(X**Y)/(Z!)))**2
Unlike FORTRAN, MACSYMA has no restriction on the mixing of
modes of operands. Integers, floating point numbers, and rational
numbers may be freely intermixed in an expression with the
priority of conversion being that integers become rational numbers
which become floating point numbers when conversions are
necessary.
In order to reduce the number of operators which must be
dealt with, MACSYMA internally represents X-Y as X+(-1)*Y and X/Y
as X*Y**(-1) but this usually need not concern the user.
Data and Statement Types page 3-4
3.6 Functions and Arrays
3.6.1 Functions
A function of a fixed number of arguments can be defined in
MACSYMA by using the := operator. The left side of a function
definition consists of the name of the function followed by the
list of formal parameters enclosed in parentheses. The right side
consists of the function body. Note that the function body though
simplified (see sect 4.0) is not evaluated at function definition
time, but only when the function is called. However, if it is
desired to evaluate some particular name or expression within the
body of a function definition, that name or expression may be
preceded by the '' operator which causes immediate evaluation of
its operand, and replacement of the operand in the input string by
its value. When a function is called, any free variables in the
function body will take on the values which they have at the time
of the call, the formal parameters will be bound to the actual
arguments and the function body will be evaluated. It is permis-
sible to define functions which are recursive to an arbitrary
depth.
The MACSYMA variable FUNCTIONS is a list of all user defined
functions.
(C1) F(X):=X**2+Y$
(C2) F(2);
(D2) Y + 4
(C3) Y:7$
(C4) F(2);
(D4) 11
(C5) G(Y,Z):=''D2+Z**2+Y;
2
(D5) G(Y, Z) := Z + 2 Y + 4
(C6) G(X,2);
(D6) 2 X + 8
(C7) FUNCTIONS;
(D7) [F(X), G(Y, Z)]
Certain commands (e.g. DEPENDENCIES) permit MACSYMA to recog-
nize that a variable depends upon other variables even if it is
not bound to an expression containing these variables. Note
Data and Statement Types page 3-5
however that this variable is not a function (in the MACSYMA
sense). A function always has its variables indicated explicitly
in a parenthesized list following the name of the function.
3.6.2 Arrays
Arrays enable one to refer to a collection of elements by
using the same name. Array elements are referred to by sub-
scripted names. A subscripted name is a name followed by a list
of subscripts. This list is enclosed in square brackets. Arrays
can be declared or undeclared. Declared arrays are similar to
FORTRAN arrays. The user declares the number of dimensions and
indicates the maximum value of each subscript. The system then
allocates space for the entire array. To declare an array the
user types the command ARRAY(name,dim1,dim2,...dimk). This sets
up a k-dimensional array. A maximum of four dimensions may be
used. The subscripts for the ith dimension are the integers
running from 0 to dimi-1. If the user uses a subscripted name
before declaring the corresponding array, an undeclared array is
set up.
Undeclared arrays, otherwise known as hashed arrays, are more
general than declared arrays. The user does not declare their
maximum size, and they grow dynamically by hashing as more ele-
ments are assigned values. The subscripts of undeclared arrays
need not even be numbers. However, unless an array is rather
sparse, it is probably more efficient to declare it than to leave
it undeclared. The ARRAY command can be used to transform an
undeclared array into a declared array.
Array elements can be assigned values explicitly with the :
operator or implicitly by means of an associated function, and the
values assigned may be any MACSYMA expression. To understand
implicit assignment we must understand what MACSYMA does when
asked to evaluate a subscripted name. MACSYMA first evaluates the
subscripts left to right. Then, if the subscripted name is not
bound to a list or matrix (see sect. 3.7, 3.8), it does an array
access to see if the requested array element already has a value.
If it does, the value is returned. If it does not, MACSYMA checks
to see whether the array has an associated function (see below).
If not, the subscripted name (with the subscripts evaluated) is
returned. (This is standard MACSYMA practice - if there is no
value for a name, the name itself is returned when an evaluation
is done.) If there is an associated function, the parameters of
the function are bound to the given subscripts, and the function
body is evaluated. The value of the function is stored in the
appropriate array element and returned. Note that once an element
is computed by the associated function it is stored so that next
time it is needed it will not be recomputed. A consequence of
this is that unless the user uses the KILL, REMOVE, or REMVALUE
commands (sect. 7.10) to kill an array element, the associated
Data and Statement Types page 3-6
function will never be called a second time on the same arguments.
Thus the user should be aware that even if he redefines the
associated function, those values which already exist will stay
around. The only way to change the value of an array element is
to use the : operator.
These associated functions are defined with the := operator.
Their definition looks exactly the same as ordinary function
definitions, except that the parameters in the left side of the
definition are enclosed in brackets instead of parentheses.
The MACSYMA variable ARRAYS is a list of all the arrays that
have been allocated, both declared and undeclared.
(C1) A[N]:=N*A[N-1]$
(C2) A[0]:1$
(C3) A[5];
(D3) 120
(C4) A[N]:=N$
(C5) A[6];
(D5) 6
(Note that the definition in C4 is being used because
A[6] has no value up to this time.)
(C6) A[4];
(D6) 24
(Since A[4] was assigned a value as a result of A[5]
being computed, the new definition is not used.)
3.6.3 Subscripted Functions (Arrays of Functions)
A collection of functions may be referred to by using a
subscripted name. Subscripted functions are defined as are
ordinary functions, using the := operator. The left side of the
definition however, consists of the function name followed by the
subscripts, enclosed in brackets, followed by the arguments,
enclosed in parentheses. The subscripts (which are not evaluated
at definition time) must be either all numeric or all symbolic.
If they are symbolic, they are treated as additional arguments to
the function.
Data and Statement Types page 3-7
(C1) T[N](X):=EXPAND(2*X*T[N-1](X)-T[N-2](X))$
(C2) T[0](X):=1$
(C3) T[1](X):=X$
(C4) T[4](Y);
4 2
(D4) 8 Y - 8 Y + 1
(C5) F[I,J](X,Y):=X**I+Y**J;
J I
(D5) F (X, Y) := Y + X
I, J
(C6) F[2,B](C,3);
2 B
(D6) C + 3
The user should realize that MACSYMA handles subscripted
functions as a special type of array, not as functions. Thus the
user should never redefine a subscripted function without KILL'ing
or REMARRAY'ing it first. If he does, he may find that the old
definition is still being invoked.
A subscripted function is actually an array of functions.
The subscripts pick out the correct function from the array. The
function is then applied to the arguments.
In order to pass a function as an argument to another
function only its name is given in the argument list of the call.
It may then be used in the called function by referencing the
corresponding dummy paramenter with a parenthesized list of argu-
ments. Subscripted functions are passed by giving the name
followed by the subscripts in brackets.
(C7) G(FUN,ARG1,ARG2):=PRINT(FUN," APPLIED TO ",ARG1," AND ",
ARG2," IS ",FUN(ARG1,ARG2))$
(C8) G(F[2,1],SIN(%PI),2*A);
2
LAMBDA([X,Y],Y+X ) APPLIED TO 0 AND 2 A IS 2 A
(D8) 2 A
The LAMBDA notation is necessary in order to indicate the
correspondence between the variables of the function and the argu-
ments which are to be substituted for them.
Data and Statement Types page 3-8
3.7 Lists
Lists are ordered sets of elements which can be any MACSYMA
expressions. They are written enclosed in brackets with elements
separated by commas. If the value of a variable is a list, its
elements may be obtained or assigned to by subscripting. In
certain cases lists are treated like vectors (row or column
matrices. see sect. 3.8) Lists are sometimes used as arguments to
MACSYMA commands (e.g. MATRIX, SOLVE, etc.). Section 7.11
describes functions for many list operations such as deleting ele-
ments, selecting an element, reversing a list, etc.
(C1) [X**2,Y/3,-2]$
(C2) %[1]*X;
3
(D2) X
(C3) [A,D1,D2];
2 Y 3
(D3) [A , [X , - , -2] , X ]
3
(C4) P:[A,B]$
(C5) P[1]:1$
(C6) P[2]::2$
(C7) P;
(D7) [1 , B]
(C8) B;
(D8) 2
3.8 Matrices
Matrices are like 2-dimensional arrays but are treated
differently in MACSYMA because of special operations defined on
them. They may be constructed by using the command MATRIX whose
arguments are lists representing the rows of the matrix. (The
commands ENTERMATRIX or GENMATRIX may also be used to construct a
MATRIX. See section 7.4).
The operators + , - , * , . , / ,and ** (for raising to a
positive or negative integer exponent) may be applied to matrices
and have their usual meaning (Note that A**(-1) or 1/A is the
inverse of the matrix A). If a matrix is multiplied by a list,
the list will be taken to be a vector. The list may multiply the
matrix on either side as long as its length conforms.
If the MACSYMA variable LISTARITH (whose default value is
FALSE) is TRUE then lists may be added to yield row matrices and
lists of equal length may be multiplied to yield a scalar (the dot
product).
An element of a matrix may be referenced by subscripting as
Data and Statement Types page 3-9
with arrays. Many functions are available for operating on
matrices and are described in section 7.4. Some examples follow:
(C1) [X**2,Y/3,-2]$
(C2) M:MATRIX([A,B],[0,1])$
(C3) M[1,1]::M[2,1]$
(D3) 0
(C4) MATRIX(D1,[0,5/2,X],REVERSE(D1));
* 2 Y *
*X - -2*
* 3 *
* *
* 5 *
(D4) *0 - X *
* 2 *
* *
* Y 2*
*-2 - X *
* 3 *
(C5) 1+%[3,3];
2
(D5) X + 1
(C6) D4[2,1]: -1/2;
(Note that this assignment actually changes the matrix D4. If it
is desired to obtain a copy of D4 so that after the assignment the
original value will be available then the command COPYMATRIX
described in sect. 7.4 should be used).
1
(D6) - -
2
(C7) MATRIX([1,X],[-X,2]);
* 1 X*
(D7) * *
* - X 2*
(C8) D7*[A,B];
(ROW TO COL CONVERSION MADE)
Data and Statement Types page 3-10
* B X + A *
(D8) * *
*2 B - A X*
(C9) TRANSPOSE(%);
(D9) *B X + A 2 B - A X*
(C10) %*D7;
(D10) * 2 2 *
*A X - B X + A B X - A X + 4 B*
(C11) D7**(-1);
* 2 X *
*------ - ------*
* 2 2 *
*X + 2 X + 2*
(D11) * *
* X 1 *
*------ ------ *
* 2 2 *
*X + 2 X + 2 *
(The determinant of a matrix whose inverse is computed is
kept inside the inverse unless the variable DETOUT is TRUE.)
(C12) SUBST(2,X,%);
*1 1*
*- - -*
*3 3*
(D12) * *
*1 1 *
*- - *
*3 6 *
(C13) LISTARITH:TRUE$
(C14) [2,A]*[1/2,2];
(D14) 2 A + 1
(C15) [1,2*A,5/2]-[2,A,1/2];
(D15) * -1 A 2*
Data and Statement Types page 3-11
3.9 Equations
An equation is formed in MACSYMA simply by using an equal
sign between any two arbitrary expressions. Equations may be
added or subtracted together, and they may be multiplied or
divided by any expression (except an equation). They may be
operated on just as any MACSYMA expression can be and sometimes
they serve as arguments to certain functions.
(C1) X+1=Y**2$
(C2) X-1=2*Y+1$
(C3) D1+D2;
2
(D3) 2 X = Y + 2 Y + 1
(C4) D1/Y;
X + 1
(D4) ----- = Y
Y
(C5) 1/%;
Y 1
(D5) ----- = -
X + 1 Y
3.10 IF Statement
The syntax is IF condition THEN expression1 ELSE expression2.
The result of an IF statement is expression1 if condition is true
and expression2 if it is false. Expression1 and expression2 are
any MACSYMA expressions (including nested IF statements), and
condition is an expression which evaluates to TRUE or FALSE and is
composed of relational and logical operators which are as follows:
Name Symbol Type
greater than > relational infix
equal to = " "
not equal to # " "
less than < " "
greater than >= " "
or equal to
less than <= " "
or equal to
not NOT logical prefix
and AND " infix
Data and Statement Types page 3-12
or OR " "
The relational operators all have equal priorities which are
less than the priorities of the arithmetic operators and greater
than that of the logical operators. The priority of NOT is
greater than that of AND which is greater than that of OR.
The ELSE clause may be omitted but not in cases where the IF
statement is expected to yield a value as in assignment. If it is
desired to have several expressions evaluated after the THEN or
ELSE clauses, the expressions may be enclosed in a list or block
(see sect 3.11) but care should be taken to return the desired
value. Examples of IF statements follow:
(C1) FIB(N):= IF N=1 OR N=2 THEN 1
ELSE FIB(N-1)+FIB(N-2)$
(C2) FIB(1)+FIB(2);
(D2) 2
(C3) FIB(3);
(D3) 2
(C4) FIB(5);
(D4) 5
(C5) ETA(MU,NU):= IF MU=NU THEN MU
ELSE IF MU>NU THEN MU-NU
ELSE MU+NU$
(C6) ETA(5,6);
(D6) 11
(C7) ETA(ETA(7,7),ETA(1,2));
(D7) 4
(C8) IF NOT 5>=2 AND 6<=5 OR 4+1>3 THEN A ELSE B;
(D8) A
3.11 Program Blocks
Blocks in MACSYMA are analogous to subroutines in FORTRAN or
procedures in ALGOL or PL/I. Blocks are useful for grouping
together a sequence of related calculations when a computation
cannot easily be expressed in a single MACSYMA statement.
The syntax is:
BLOCK([v1,...,vk], stmt-1,...,stmt-n)
where the vi are variables which are local to the BLOCK and the
stmt-i are any MACSYMA expressions. If no variables are to be
made local then the list may be omitted but then any variables
used within the block will be identical to variables with the same
Data and Statement Types page 3-13
names used outside of it.
The value of the block is the value of the last statement or
the value of the argument to the function RETURN which may be used
to exit explicitly from the block. In addition the function GO
may be used to transfer control to the statement of the block that
is labeled with the argument to GO. To label a statement precede
it by an atomic symbol as another argument to BLOCK. For example
BLOCK([X],X:1,LOOP,X:X+1,...,GO(LOOP),...). The argument to GO
may be any expression which evaluates to a label. For example
GO(IF X>Y THEN PLACE1 ELSE COMPUTEPLACE(X)). Going out of a block
causes the unbinding of all variables which were bound in the
block. Blocks typically appear on the right side of a function
definition but can be used in other places as well.
(C1) HESSIAN(F):=BLOCK([DFXX,DFXY,DFXZ,DFYY,DFYZ,DFZZ],
DFXX:DIFF(F,X,2),DFXY:DIFF(F,X,1,Y,1),DFXZ:DIFF(F,X,1,Z,1),
DFYY:DIFF(F,Y,2),DFYZ:DIFF(F,Y,1,Z,1),DFZZ:DIFF(F,Z,2),
DETERMINANT(MATRIX([DFXX,DFXY,DFXZ],[DFXY,DFYY,DFYZ],
[DFXZ,DFYZ,DFZZ])))$
(C2) HESSIAN(X**3-3*A*X*Y*Z+Y**3);
3 2 3 2 3
(D2) - 54 A X Y Z - 54 A Y - 54 A X
(C3) SUBST(1,Z,QUOTIENT(%,-54*A**2));
3 3
(D3) X + A Y X + Y
The above example computes the Hessian of a cubic curve (the
Folium of Descartes) which turns out to be invariant under this
transformation, i.e. the result is of the same form.
3.12 The DO Statement
The DO statement is useful in performing iteration. Due to
its great generality it will be described in two parts. First the
usual form will be given which is analogous to that used in
several other programming languages (FORTRAN, ALGOL, PL/I, etc.).
Then the other features will be mentioned (the beginner may wish
to skip over these on the first reading).
3.12.1 Commonly Used Form
There are three variants of this form that differ only in
their terminating conditions. They are:
Data and Statement Types page 3-14
(a) FOR variable:initial-value STEP increment
THRU limit DO body
(b) FOR variable:initial-value STEP increment
WHILE condition DO body
(c) FOR variable:initial-value STEP increment
UNLESS condition DO body
(Alternatively, the STEP may be given after the termination
condition.)
The initial-value, increment, limit, and body can be any
expressions. If it is desired to iterate over several
statements then the body may be a list of them (see 3.7). The
condition is as in the IF statement. If the increment is 1 then
"STEP 1" may be omitted.
The execution of the DO statement proceeds by first
assigning the initial-value to the variable (henceforth called
the control-variable). Then: (1) If the control-variable has
exceeded the limit of a THRU specification, or if the condition
of the UNLESS is TRUE, or if the condition of the WHILE is FALSE
then the DO terminates. (2) The body is evaluated. (3) The
increment is added to the control-variable. The process from
(1) to (3) is performed repeatedly until the termination condi-
tion is satisfied. One may also give several termination condi-
tions in which case the DO terminates when any of them are
satisfied.
In general the THRU test is satisfied when the
control-variable is greater than the limit if the step was
non-negative, or when the control-variable is less than the
limit if the step was negative. The step and limit may be
non-numeric expressions as long as this inequality can be
determined. However, unless the step is known to be negative
(i.e. is a negative number) at the time the DO statement is
input, MACSYMA assumes it will be positive when the DO is
executed. If it is not, then the DO may not terminate properly.
Note that the limit, increment, and termination condition
are evaluated each time through the loop. Thus if any of these
involve much computation, and yield a result that does not
change during all the executions of the body, then it is more
efficient to set a variable to their value prior to the DO and
use this variable in the DO form.
The value normally returned by a DO statement is the atom
DONE, as every statement in MACSYMA returns a value. However,
the function RETURN (see 3.11) may be used inside the body to
exit the DO prematurely and give it any desired value.
The control-variable is always local to the DO and thus any
variable may be used without affecting the value of a variable
with the same name that was given a value prior to the
Data and Statement Types page 3-15
execution of the DO. The control-variable is unbound after the
DO terminates.
(C1) FOR A:-3 THRU 26 STEP 7 DO DISPLAY(A)$
(E1) A = -3
(E2) A = 4
(E3) A = 11
(E4) A = 18
(E5) A = 25
(C6) S:0$
(C7) FOR I:1 WHILE I<=10 DO S:S+I;
(D7) DONE
(C8) S;
(D8) 55
(Note that the condition in C7 is
equivalent to UNLESS I>10 and also THRU 10)
(C9) SERIES:1$
(C10) TERM:EXP(SIN(X))$
(C11) FOR P:1 UNLESS P>7 DO
[TERM:DIFF(TERM,X)/P,
SERIES:SERIES+SUBST(X=0,TERM)*X**P]$
(C12) SERIES;
7 6 5 4 2
(D12) X X X X X
-- - --- - -- - -- + -- + X + 1
96 240 15 8 2
This example computes seven terms of the Taylor series for
e**SIN(X) (a TAYLOR command is also available - see sect. 7.5).
(C13) POLY:0$
(C14) FOR I:1 THRU 5 DO
FOR J:I STEP -1 THRU 1 DO
POLY:POLY+I*X**J$
(C15) POLY;
5 4 3 2
(D15) 5 X + 9 X + 12 X + 14 X + 15 X
(C16) GUESS:-3.0$
(C17) FOR I:1 THRU 10 DO [GUESS:SUBST(GUESS,X,.5*(X+10/X)),
IF ABS(GUESS**2-10)<.00005 THEN RETURN(GUESS)];
(D17) - 3.1622807
This example computes the negative square root of 10 using
the Newton-Raphson iteration a maximum of 10 times. Had the
convergence criterion not been met the value returned would have
Data and Statement Types page 3-16
been "DONE".
3.12.2 Additional Features of the DO Statement
Instead of always adding a quantity to the control-variable
one may sometimes wish to change it in some other way for each
iteration. In this case one may use "NEXT expression" instead
of "STEP increment". This will cause the control-variable to be
set to the result of evaluating expression each time through the
loop.
(C1) FOR COUNT:2 NEXT 3*COUNT THRU 20
DO DISPLAY(COUNT)$
(E1) COUNT = 2
(E2) COUNT = 6
(E3) COUNT = 18
Sometimes one may be interested in performing an iteration
where the control-variable is never actually used. It is thus
permissable to give only the termination conditions omitting the
initialization and updating information as in the following
example to compute the square-root of 5 using a poor initial
guess.
(C1) X:1000
(C2) THRU 10 WHILE X#0.0 DO X:.5*(X+5.0/X)$
If it is desired one may even omit the termination condi-
tions entirely and just give "DO body" which will continue to
evaluate the body indefinitely. In this case the function
RETURN (see 3.11) should be used to terminate execution of the
DO.
(C1) NEWTON(F,GUESS):=BLOCK([DF,Y],
DEFINE(DF(X),DIFF(F(X),X)),
DO [Y:DF(GUESS), IF Y=0.0 THEN ERROR(
"DERIVATIVE AT",GUESS," IS ZERO"),
GUESS:GUESS-F(GUESS)/Y,
IF F(GUESS)=0.0 THEN RETURN(GUESS)])$
(C2) SQR(X):=X**2-5.0$
(C3) NEWTON(SQR,1000);
(D3) 2.236068
(Note that RETURN, when executed, causes the current value of
GUESS to be returned as the value of the DO. The BLOCK is
exited and this value of the DO is returned as the value of the
Data and Statement Types page 3-17
BLOCK because the DO is the last statement in the block.)
One other form of the DO exists in MACSYMA. The syntax is:
FOR variable IN list {end-tests} DO body
The members of the list (see 3.7) are any expressions which
will successively be assigned to the variable on each iteration
of the body. The optional end-tests can be used to terminate
execution of the DO, otherwise it will terminate when the list
is exhausted or when a RETURN is executed in the body.
(C1) FOR F IN [SIN, RHO, ATAN] DO DISP(F(1.0))$
(E1) SIN(1.0)
(E2) RHO(1.0)
(E3) ATAN(1.0)
(C3) E3,NUMER;
(D3) .78539816
Representation, Evaluation, and Simplification page 4-1
4.0 Representation, Evaluation, and Simplification
It has already been mentioned parenthetically (sect. 3.5)
that in the internal form of MACSYMA expressions, division is rep-
resented by multiplication of the numerator by the denominator to
the -1 power and subtraction by addition of the negative of the
subtrahend. Usually the user need not be concerned with the
internal workings of MACSYMA, but some knowledge of the repre-
sentation of expressions and of the way in which they are
evaluated and simplified should be acquired in order to use
MACSYMA more easily, efficiently, and effectively.
Representation
The expressions which are input by the user and those which
are displayed by MACSYMA are in an "external" form. The displayed
form has been formatted with its variables specially ordered and
thus it may not appear identical to an expression as it was input.
After an expression is input it is automatically translated
to a LISP "internal" form. This is the form in which MACSYMA's
programs deal with expressions and is of three types.
The general form represents expressions as LISP lists whose
first element is the main operator of the expression and whose
remaining elements are the operands also represented in this form.
Thus 2*X+3/4 is represented (glossing over inessential details) as
(PLUS (RAT 3 4) (TIMES 2 X)). Any expression which MACSYMA deals
with can be represented in this form. The general form also
carries additional information about the expression such as
whether it is factored or not whereas the other forms require that
the expression be fully expanded.
The second form called CRE (for Canonical Rational Expression)
is especially suitable for sparse polynomials and rational
functions. Since matrix elements are usually rational functions,
the default is to represent them in CRE form. In this form an
ordering of variables is assumed for each expression. Polynomials
are represented recursively by a list consisting of the main
variable followed by a series of pairs of expressions, one for
each term of the polynomial. The first member of each pair is the
exponent of the main variable in that term and the second member
is the coefficient of that term which could be a number or a poly-
nomial in another variable again represented in this form. Thus
the CRE form of 3*X**2-1 is (X 2 3 0 -1) and the CRE form of
2*X*Y+X-3 is (Y 1 (X 1 2) 0 (X 1 1 0 -3)) assuming Y is the main
variable, and is (X 1 (Y 1 2 0 1) 0 -3) assuming X is the main
variable.
The "variables" of a CRE expression needn't be atomic, in
fact any subexpression whose main operator is not + , - , * , / ,
or ** to an integer power will be considered a "variable" of the
expression (in CRE form) in which it occurs. For example the CRE
Representation, Evaluation, and Simplification page 4-2
variables of the expression X**(5/2)+SIN(X+1)+SQRT(X)*2+1 are
SQRT(X), and SIN(X+1).
The user can specify an ordering of variables or he can let
MACSYMA choose an alphabetic one. CRE's in general represent
rational expressions, that is, ratios of polynomials, where the
numerator and denominator have no common factors, and the denom-
inator is positive. The internal form is essentially a list of
two polynomials, the numerator and denominator preceded by the
variable ordering list. (see the RATVARS command - sect. 7.6)
Note that constants, when represented in this form, appear
quite different than they do in general form. For example the
general form of 0 is simply 0, but the CRE form is a list
including 0 for the numerator and 1 for the denominator among
other things.
In the third form of MACSYMA expressions, the notion of a
rational function is extended so that the exponents of the
variables can be positive or negative rational numbers rather than
just positive integers and the coefficients can themselves be the
rational functions described above rather than just polynomials.
These are represented internally by a recursive form which is
similar to, and is a generalization of CRE form, but carries
additional information such as the degree of truncation of the
variables in power series.
Additional variants to CRE form (e.g. partially factored)
will be available later, and will be described in a future edition
of this manual.
Evaluation and Simplification
After MACSYMA parses an input expression, it is evaluated and
simplified and the result is displayed. Often the two-phase
process of evaluation and simplification is referred to simply as
"evaluation." In this section though, we use the word "evalua-
tion" to refer only to the evaluation stage proper and not to the
simplification stage.
MACSYMA expressions are strings consisting of numbers, names,
function calls, and operators. The evaluation phase proceeds by
building up a string which is similar in form to the input expres-
sion, but has certain substitutions. The evaluator is recursive,
and calls itself on all sub-expressions.
When the evaluator sees a name, it checks to see whether the
name has a value assigned to it. If there is a value, the value
is returned by the evaluator. If there is no value assigned to
the name, the evaluator just returns the name itself. (For the
means of assigning values to names refer to section 3.4. For a
description of the evaluation process as applied to subscripted
names see section 3.6.2).
When the evaluator sees a function call, it checks to see
whether the function is noun-type or verb-type (all functions are
Representation, Evaluation, and Simplification page 4-3
one or the other). If the function is verb-type, the evaluator
evaluates the arguments and then applies the function to them.
The value which the function returns is returned by the evaluator.
If the function is noun-type, the evaluator returns an expression
identical to the function call, except that the arguments are
replaced by their evaluations. Most functions in the system,
including all user-defined functions, are initially considered to
be verb-type. Undefined functions and some system functions are
considered to be noun-type.
The user can explicitly declare a function to be noun-type by
using the NOUN command (sect. 7.10). For example, DIFF normally
tries to differentiate its first argument. After the command
NOUN(DIFF) is given however, DIFF will not perform the differen-
tiation. Also in some cases where a command cannot perform the
required operation on the given arguments it returns the noun-form
of itself. If this was because of some values not being assigned,
which the user supplies at a later time, he can cause the
noun-form to be re-evaluated at that time by simply typing the
label of that line followed by the name of the unexecuted command
separated with a comma. For example:
(C1) DIFF(X*F(X),X);
D
(D1) X (-- F(X)) + F(X)
DX
(C2) F(X):=SIN(X)$
(C3) D1,DIFF;
(D3) SIN(X) + X COS(X)
Thus we see that the expression returned by the evaluator is
similar to the input expression. The basic difference is that
names which have values are replaced by their values and verb-type
function calls are replaced by the result of applying the function
to its arguments. Real changes in the form of the expression come
during the simplification phase.
The simplifier, which knows a lot of algebra, takes the
output of the evaluator and then tries to make it smaller and more
manageable. Unless the user takes some special action (like
setting the special variable SIMP to FALSE), MACSYMA will never
output an unsimplified expression.
The user should be aware that the line between evaluation and
simplification is far from clear-cut. For instance, SIN is a
noun-function. When the evaluator sees SIN(0), it returns SIN(0).
However, the simplifier notices this special case and changes this
expression to 0. So simplification will sometimes obscure the
difference between noun and verb functions.
Note that an expression often undergoes a reordering during
Representation, Evaluation, and Simplification page 4-4
simplification and that whereas in most lines the user types in,
evaluation occurs before simplification, in defining a function
simplification occurs first. (Of course, when the function is
invoked it is evaluated and the result is then simplified as
usual.)
This implies that terms within expressions that the function
contains may be re-ordered so that side-effects may not occur as
intended. In general, it is unwise to attempt side-effects within
the operands of an algebraic expression. An example should make
this clear.
(C1) (X:3)*X;
(D1) 9
(C2) F():=(X:3)*X;
(D2) F():= X (X:3)
(C3) F();
(D3) 3 X
MACSYMA has several special operators which give the user
some control over the evaluation process. The single-quote
operator ( ' ) has the effect of preventing evaluation. Thus an
expression preceded by a single-quote evaluates to that expres-
sion. The one exception to this is that the evaluation of the
single-quote operator followed by a function call is the evalua-
tion of the function call, treated as though the function were
noun-type.
The quote-quote operator ( '' ) is best considered as a macro
character. Inputting an expression preceded by a quote-quote has
exactly the same effect as inputting the result of evaluating and
simplifying the expression. In other words when an inputted ex-
pression contains a sub-expression which begins with a quote-quote
that sub-expression is replaced in the input string by the result
of evaluating and simplifying the expression following the
quote-quote. This occurs at the time an expression is parsed.
(C1) X;
(D1) X
(C2) X:3$
(C3) X;
(D3) 3
(C4) 'X;
(D4) X
(C5) F(X):=X↑2;
2
(D5) F(X) := X
Representation, Evaluation, and Simplification page 4-5
(C6) 'F(2);
(D6) F(2)
(C7) %,F;
(D7) 4
(C8) '(F(2));
(D8) F(2)
(C9) ''%;
(''atom means evaluate the atom's value)
(D9) 4
(C10) NOUN(INTEGRATE)$
(C11) INTEGRATE(Y**2,Y);
/
[ 2
(D11) I Y DY
]
/
(C12) ''INTEGRATE(Y**2,Y);
3
Y
(D12) --
3
(C13) F(Y):=DIFF(Y*LOG(Y),Y,2);
2
D
(D13) F(Y) := --- Y LOG(Y)
2
DY
(C14) F(Y):=''DIFF(Y*LOG(Y),Y,2);
1
(D14) F(Y) := -
Y
(C15) C14;
1
(D15) F(Y) := -
Y
Representation, Evaluation, and Simplification page 4-6
(Notice that the input expression has been changed due to the use of ''.)
Referring to line (C14) above, suppose one wished to define
the function F(Y) as DIFF(Y*LOG(Y),Y,I) within another function
G(I) where the I in the definition of F(Y) is to be replaced by
the argument to G when G is called.
G(I):=BLOCK(...,F(Y):=''DIFF(Y*LOG(Y),Y,I),...) will not do the
job because the '' operator will cause the differentiation to be
carried out at parse time and thus either an error will result (if
I is unbound) or the current global value of I will be used rather
than the value of the argument to G when it is called.
(F(Y):=DIFF(...) is also not desirable in this example because
that would force the differentiation to be done at the time F is
called rather than at the time it is defined.) To remedy this one
may use the command DEFINE(function(arguments),body) which is like
function(arguments):=''body but which causes the evaluation of
body to occur at the time DEFINE is evaluated. Thus
G(I):=BLOCK(...,DEFINE(F(Y),DIFF(Y*LOG(Y),Y,I)),...) will work
properly.
Miscellaneous Hints page 5-1
5.0 Miscellaneous Hints and Facilities
Care should be taken in cases where an expression containing
% is re-evaluated since the value of % changes each time a new
line is computed. This mistake is shown in the following example.
(C1) (X+Y)**3$
(C2) RAT(%,X);
3 2 2 3
(D2) X + 3 X Y + 3 X Y + Y
(C3) X:Y**2+1$
(C4) ''C2;
2
(D4) Y + 1
Here the user intended to substitute for X in C1 and to cause
C2 to be re-evaluated however % in C2 refers to D3 rather than D1
at the time of re-evaluation. Note the use of the '' operator to
re-evaluate a previous expression.
The following interrupt characters typed while holding down
the control key have special functions.
G - enters top-level LISP after resetting all bound
variables and breaking out of all functions. It is not
possible to continue an interrupted calculation after a
control-G, but typing (CONTINUE) will return to MACSYMA.
↑ - aborts a computation and returns control to
top-level MACSYMA. This is like control-G immediately
followed by (CONTINUE) and is useful for breaking out of
infinite loops.
H - makes a "breakpoint" in MACSYMA, enters LISP, and
prints the time used in the current computation. Control-H
does not reset any values. Altmode (or Escape) P followed by
a space will return to MACSYMA and resume the computation.
A - similar to control-H except that MACSYMA has control
at this breakpoint. To exit type EXIT; (see sect. 12.0).
] - prints the time used so far in a computation
(without interrupting it).
D - causes garbage collection statistics to be printed
out each time a garbage collection takes place [19,30]. If
the percentages drop below 5% consistently, it may be that
the computation is too large for the MACSYMA system being
used. Usually however if the user kills some previous but
unnecessary results (see 7.10) or stores away previous
results which aren't presently needed (see 10.3) or
reorganizes his computation this problem can be alleviated.
C - stops printout of garbage collection statistics
turned on by control-D.
Miscellaneous Hints page 5-2
K - reprints the current input line. This is useful
when many rubouts have obscurred the line.
L - clears the screen on display consoles and reprints
the current line.
W - stops printout at the console (the computation
continues).
V - resumes printout at the console turned off by
control-W.
B - seizes the lineprinter so that subsequent output at
the user's console will also be printed.
E - frees the lineprinter which was seized by control-B.
Sometimes when a user gives a command the message "...
BEING LOADED" will be printed. This means that the command
used and/or the associated programs are not in the initially
loaded MACSYMA but are being loaded in now via the dynamic
loader. Infrequently used commands are not initially loaded
into MACSYMA in an effort to save space.
When in LISP typing (CONTINUE) will return to MACSYMA.
Typing (SUPERVISOR) will also return to MACSYMA but will do a
KILL(LABELS) in addition, thus clearing the environment of
all C, D and E expressions. (see section 7.10).
There is a special file on the ITS system for holding
comments from users which are of general interest and for
listing changes to MACSYMA which occur from time to time.
The DDT command :MAIL MACSYM followed by a carriage return
and text terminated by a control-C is used to place comments
in this mail file. The user's login name and time of message
are added automatically. The user may also send mail to
other users using the :MAIL command followed by the user's
login name. If the user has received mail the message
--MAIL-- will appear on his console after he logs in. Typing
a space will cause the mail to be printed. The DDT command
:PRMAIL MACSYM is used to print out the MACSYMA mail file.
The user should do this occasionally to be informed of
changes to the system and of other users' comments. :PRMAIL
may also be used to print out any user's mail by following it
with the user's login name. Control-S may be used to silence
the printout. In addition the command :PRINT
DSK:MACSYM;UPDATE > may be used to print a file describing
updates to MACSYMA since the last version of the manual.
The > sign in a file name signifies the "greatest" name
in an alphabetic ordering. A < sign may also be used to
signify the "least" name.
For further information on DDT commands see [25].
Typing :? will list the commands with a brief description.
Constants and Functions page 6-1
6.0 Predefined Mathematical Constants and Functions
Constants
%E - is the base of the natural logarithms. It also
serves as an alternative to the exponential function below,
i.e. %E**X is equivalent to EXP(X).
%PI - is used to symbolically stand for pi.
%I - is the square root of -1.
INF - is real positive infinity.
MINF - is real minus infinity.
INFINITY - is complex infinity.
(Note: At present the infinity symbols have meaning only for
certain commands like LIMIT, INTEGRATE, SUM, etc.)
TRUE - is the boolean constant true. (T in LISP)
FALSE - is the boolean constant false. (NIL in LISP)
Functions
All of the functions mentioned below take one argument
(shown as X) unless stated otherwise. Certain properties are
indicated in braces following each function.
Properties
N: the function can be evaluated for numeric
arguments by using the NUMER flag of EV.
(see section 7.1)
ND: the function can't be differentiated.
S: the function is automatically simplified
only for certain numeric arguments.
(such as integers or special angles).
A: the function is automatically evaluated
for any numeric argument.
Constants and Functions page 6-2
Simple Functions
ABS {A,ND} - absolute value.
ABSBOXCHAR [*] is the character used to draw
absolute value signs around expressions of more
than a single line high.
ENTIER {A,ND} - largest integer <= X.
SIGNUM {A,ND} - if X<0 then -1 else if X>0 then 1 else 0.
If X is not numeric then a simplified but equivalent
form is returned. (e.g. SIGNUM(-X) gives -SIGNUM(X) )
POLYSIGN {A,ND} - same as SIGNUM but always returns a numerical
result by looking at the numerical factor of X.
MIN(X1,X2,...) {A,ND} yields the minimum of its arguments.
(or returns a simplified form if some of its arguments
are non-numeric)
MAX(X1,X2,...) {A,ND} yields the maximum of its arguments.
(or returns a simplified form if some of its arguments
are non-numeric)
Miscellaneous Functions
SQRT {N,S} - same as X**(1/2)
EXP {N,S} - the exponential function.
LOG {N,S} - the natural logarithm.
BINOMIAL(X,Y) {S,ND} - X*(X-1)*...*(X-Y+1)/Y!. If X
and Y are integers, the binomial coefficient is
actually computed. If Y or X-Y is an integer, the
binomial coefficient is simplified to a polynomial.
FIBB {S,ND} - the Xth Fibonacci number.
GENFACT(X,Y,Z) {S,ND} is the generalized factorial of X
which is:
X*(X-Z)*(X-2*Z)*...*(X-(Y-1)*Z).
Thus GENFACT(X,X,1)=X! and GENFACT(X,X/2,2)=X!!
GAMMA {N,S} - the gamma function. GAMMA(I)=(I-1)!
for I a positive integer.
The value of the variable FACTLIM [initially -1]
is the highest integral argument of the GAMMA function
to be evaluated automatically.
Initially all integral values of the GAMMA function
are evaluated automatically.
BETA(X,Y) {N,S,ND} - same as GAMMA(X)*GAMMA(Y)/GAMMA(X+Y)
EULER {ND,S} - gives the Xth EULER number for integer X.
BERN {ND,S} - gives the Xth BERNOULLI number for integer X.
The switch ZEROBERN [initially TRUE] if set to FALSE
excludes the zero BERNOULLI numbers.
ZETA {ND,S} - gives the Riemann zeta function for
certain integer values of X.
PSI {ND} - derivative of LOG(GAMMA(X)).
Constants and Functions page 6-3
Circular Functions
COS {N,S} - cosine.
SIN {N,S} - sine.
TAN {N,S} - tangent.
SEC {N,S} - secant.
CSC {N,S} - cosecant.
COT {N,S} - cotangent.
Inverse Circular Functions
ACOS {N,S} , ASIN {N,S} , ATAN {N,S}
ASEC {N,S} , ACSC {N,S} , ACOT {N,S}
Hyperbolic Functions
COSH {N,S} , SINH {N,S} , TANH {N,S}
SECH {S} , CSCH {S} , COTH {S}
Inverse Hyperbolic Functions
ACOSH , ASINH , ATANH , ASECH , ACSCH, ACOTH
Examples
(C1) SIN(%PI/12)+TAN(%PI/6);
%PI 1
(D1) SIN(---) + -------
12 SQRT(3)
(C2) %,NUMER;
(D2) 0.8361693
(C3) BETA(1/2,2/5);
2
SQRT(%PI) GAMMA(-)
5
(D3) ------------------
9
GAMMA(--)
10
(C4) %,NUMER;
(D4) 3.6790924
Constants and Functions page 6-4
(C5) DIFF(ATANH(SQRT(X)),X);
1
(D5) -----------------
2 SQRT(X) (1 - X)
Complex Expressions
Complex expressions are specified in MACSYMA by adding
its real part to %I times its imaginary part. Thus the roots
of the equation X**2-4*X+13=0 are 2+3*%I and 2-3*%I.
Examples
(C1) (SQRT(-4)+SQRT(2.25))**2;
2
(D1) (2 %I + 1.5)
(C2) EXPAND(%);
6.0 %I - 1.75
(C3) EXPAND(SQRT(2*%I));
(D3) %I + 1
Note that simplification of products of complex expres-
sions can be effected by expanding the product.
Simplification of quotients, roots, and other functions of
complex expressions can usually be accomplished by using the
REALPART and IMAGPART commands (see 7.2).
General Purpose Commands page 7.0-1
7.0 MACSYMA Commands and Variables
Following is a list of all MACSYMA Commands divided into
functional classes. Special variables are mentioned in the
description of some commands which affect their operation.
Their default value is enclosed in brackets.
7.1 General Purpose
The commands in this section are (1) used to change the
form rather than the value of an expression (e.g. expanding,
factoring, etc.) (2) used to effect general types of manipu-
lation (e.g. summing) or (3) related to differentiation and
integration.
EV(exp,arg1,...,argn) causes the expression exp to be evaluated
and simplified with according to the values of the argi.
These may be as follows:
EVAL causes an extra evaluation of the expression after
all other switches are acted upon.
SIMP causes the expression to be simplified regardless of
the setting of the switch SIMP which inhibits simplification
if FALSE.
EXPAND causes expansion. EXPAND(n,m) set the values of
MAXPOSEX and MAXNEGEX. (see the EXPAND command below)
RATSIMP causes the expression to be rationally simpli-
fied. (see the RATSIMP command below)
FACTOR causes the expression to be factored. (see the
FACTOR command below)
DIFF causes all differentiations indicated in exp to be
performed. DERIVLIST(var1,...,vark) causes only
differentiations with respect to the indicated variables. (see
the DIFF command below)
NUMER causes some mathematical functions (including
exponentiation) with numerical arguments to be evaluated. (see
section 6.0)
FLOAT causes rational numbers, which are not integers, to
be converted to floating point. (The NUMER flag also causes
this.)
PRED causes predicates (expressions which evaluate to
TRUE or FALSE) to be evaluated.
v=expression causes the assignment of expression to v in
exp in parallel with any other assignments being performed.
Note that if v is a MACSYMA special variable or switch, then
expression is used for its value during the evaluation of exp.
If v is not an atom but an expression then a substitution
rather than an assignment is done.
In addition a list of equations may be given (e.g. [X=1 ,
General Purpose Commands page 7.0-2
Y=A**2] ) or a list of names of equations (e.g. [E1,E2] where
E1 and E2 are equations) such as that returned by SOLVE.
Any other function names (e.g. SUM) cause evaluation of
occurrences of those names as though they were verbs (see
sect. 4.0).
The argi of EV may be given in any order. The SIMP,
NUMER, FLOAT, and PRED switches may also be set locally in a
block, or globally at the "top level" in MACSYMA so that they
will remain in effect until being reset. The NUMER flag
however, floats rational numbers only when given to EV
directly.
(C1) SIN(X)+COS(Y)+(W+1)**2+'DIFF(SIN(W),W);
D 2
(D1) COS(Y) + SIN(X) + --SIN(W) + (W + 1)
DW
(C2) EV(%,NUMER,EXPAND,DIFF,X=2,Y=1);
2
(D2) COS(W) + W + 2 W + 2.4495997
An alternate "top level" syntax has been provided for EV,
whereby one may just type in its arguments, without the EV().
That is, one may write simply exp,arg1,...,argn. (This is not
permitted as part of another expression, i.e. in functions,
blocks, etc.)
(C3) X+Y,X=A+Y,Y=2;
(D3) Y + A + 2
(Notice the parallel substitution process)
General Purpose Commands page 7.0-3
(C4) 2*X-3*Y=3$
(C5) -3*X+2*Y=-4$
(C6) SOLVE([D4,D5]);
SOLUTION
1
(E6) Y = - -
5
6
(E7) X = -
5
(D7) [E6, E7]
(C8) D5,D7;
(D8) - 4 = - 4
(C9) X+1/X > GAMMA(1/2);
1
(D9) X + - > SQRT(%PI)
X
(C10) %,NUMER,X=1/2;
(D10) 2.5 > 1.7724539
(C11) %,PRED;
(D11) TRUE
EXPAND(exp) will cause an expansion of its argument. That is,
products of sums and exponentiated sums will be multiplied
out, numerators of rational functions which are sums will be
split into their respective terms, and multiplication
(commutative and non-commutative) will be distributed over
addition. The MACSYMA variables MAXNEGEX and MAXPOSEX
(originally set to 6) control the maximum negative and
positive exponents, respectively, which will expand.
EXPAND(exp,p,n) expands exp, using p for MAXPOSEX and n for
MAXNEGEX.
(C1) EXPAND((2*X-3*Y)**3);
3 2 2 3
(D1) - 27 Y + 54 X Y - 36 X Y + 8 X
General Purpose Commands page 7.0-4
RATEXPAND(exp) expands exp by multiplying out products of sums and
exponentiated sums, combining fractions over a common denom-
inator then splitting the numerator (if a sum) into its
respective terms and cancelling the greatest common divisor of
the numerator and denominator of the terms.
RATEXPAND [FALSE] - if TRUE will cause CRE expressions to
be displayed as if they were RATEXPANDed.
RATDENOMDIVIDE [TRUE] - if FALSE will stop the splitting
up of the terms of the numerator of RATEXPANDed expressions
from occurring. EXPAND causes expansion of each term of a sum
separately, whereas RATEXPAND causes each term of a sum to be
placed over a common denominator (if RATDENOMDIVIDE is TRUE)
as the following example illustrates.
(C1) (X-1)/(X+1)**2+1/(X-1);
X - 1 1
(D1) -------- + -----
2 X - 1
(X + 1)
(C2) EXPAND(D1);
X 1 1
(D2) ------------ - ------------ + -----
2 2 X - 1
X + 2 X + 1 X + 2 X + 1
(C3) RATEXPAND(D1);
2
2 X 2
(D3) --------------- + ---------------
3 2 3 2
X + X - X - 1 X + X - X - 1
MULTTHRU(expr) expr must be a product containing at least one sum.
That is f1*f2*...*fn where at least one factor say fi is a sum
of terms. Each term in that sum is multiplied by the other
factors in the product. (Namely all the factors except fi).
This is useful for dividing the terms of the numerator of a
rational expression by the denominator without causing expan-
sion. MULTTHRU can also be used to distribute non-commutative
product through sums i.e., MULTTHRU(A.(B+C)) gives A.B+A.C
MULTTHRU(exp1,exp2) multiplies each term in exp2 (which must be a
sum) by exp1.
General Purpose Commands page 7.0-5
(C1) X/(X-Y)**2-1/(X-Y)-F(X)/(X-Y)**3;
1 X F(X)
(D1) - ----- + -------- - --------
X - Y 2 3
(X - Y) (X - Y)
(C2) MULTTHRU((X-Y)**3,%);
2
(D2) - (X - Y) + X (X - Y) - F(X)
(C3) RATSIMP(D2);
2
(D3) - Y + X Y - F(X)
(C4) ((A**2+B**2)*S**2+2*A*B*S+(A*B)**2)/(A*B*S**2);
2 2 2 2 2
(B + A ) S + 2 A B S + A B
(D4) ------------------------------
2
A B S
(C5) MULTTHRU(%);
2 2
2 A B B + A
(D5) - + --- + -------
S 2 A B
S
RATSIMP(exp) rationally simplifies the expression exp. That is,
exp is converted into a single fraction, whose numerator and
denominator are polynomials over the integers, with no common
factors. exp is written in a recursive form: a polynomial in
the main variable whose coefficients are polynomials in the
next-higher-order variable, ..., whose coefficients are
integers. This is accomplished by converting exp into CRE
form ( see 4.0), and then converting back to ordinary MACSYMA
form (at which time general simplifications are done).
Note that the "variables" of exp needn't be atomic. (see
ex. C3 below)
General Purpose Commands page 7.0-6
(C1) 2*X/(X+Y)**2-3/(X+Y)+1/(X-Y);
1 3 2 X
(D1) ----- - ----- + --------
X - Y Y + X 2
(Y + X)
(C2) RATSIMP(%);
2
4 Y
(D2) - ---------------------
3 2 2 3
Y + X Y - X Y - X
(C3) ((X-1)↑(3/2)-(X+1)*SQRT(X-1))/SQRT((X-1)*(X+1));
3/2
(X - 1) - SQRT(X - 1) (X + 1)
(D3) --------------------------------
SQRT(X - 1) SQRT(X + 1)
(C4) RATSIMP(%);
2
(D4) - -----------
SQRT(X + 1)
XTHRU(expr) combines all terms of expr over a common denominator
without expanding products and exponentiated sums as RATSIMP
does. XTHRU cancels common factors in the numerator and
denominator of rational functions if the factors are explicit.
Sometimes it is better to use XTHRU before RATSIMPing an
expression in order to cause explicit factors of the gcd of
the numerator and denominator to be canceled thus simplifying
the expression to be RATIMPed.
(C1) 1/(X+1)-X/(X+1)**2+((X+2)**2-1)/(X+1)**2;
2
(X + 2) - 1 1 X
(D1) ------------ + ----- - --------
2 X + 1 2
(X + 1) (X + 1)
General Purpose Commands page 7.0-7
(C2) XTHRU(%);
2
(X + 2)
(D2) --------
2
(X + 1)
RADCAN(exp) simplifies exp by converting it into a form which is
canonical over a large class of expressions and a given
ordering of variables; that is, all functionally equivalent
forms are mapped into a unique form. For a somewhat larger
class of expressions, RADCAN produces a normal form; that is,
all forms equivalent to zero are mapped into zero. For purely
rational expressions, RADCAN is no more time-consuming than
RATSIMP. However, for more general expressions including
radicals, logs, and non-integer exponents, RADCAN can be quite
expensive. This is the cost of exploring certain relation-
ships among the components of the expression for simpli-
fications based on factoring and partial-fraction expansions
of exponents.
(C1) (LOG(X↑2+X)-LOG(X))↑A/LOG(X+1)↑(A/2);
2 A
(LOG(X + X) - LOG(X))
(D1) -----------------------
A/2
LOG(X + 1)
(C2) RADCAN(%);
A/2
(D2) LOG(X + 1)
(C3) LOG(A**(2*X)+2*A**X+1)/LOG(A**X+1);
2 X X
LOG(A + 2 A + 1)
(D3) --------------------
X
LOG(A + 1)
(C4) RADCAN(%);
(D4) 2
(C5) (%E**X-1)/(%E**(X/2)+1);
General Purpose Commands page 7.0-8
X
%E - 1
(D5) ---------
X/2
%E + 1
(C6) RADCAN(%);
X/2
(D6) %E - 1
PARTFRAC(exp,var) expands the expression exp in partial fractions
with respect to the main variable, var.
The algorithm employed is based on the fact that the
denominators of the partial fraction expansion (the factors of
the original denominator) are relatively prime. The numer-
ators can be written as linear combinations of denominators,
and the expansion falls out.
(C1) -(X-1)/(X**3+X**2+X+1);
X - 1
(D1) - ---------------
3 2
X + X + X + 1
(C2) PARTFRAC(D1,X);
1 X
(D2) ----- - ------
X + 1 2
X + 1
FACTOR(exp) factors the expression exp, containing any number of
variables or functions, into factors irreducible over the
integers. If exp is a rational expression (with a denominator
not 1) both numerator and denominator are factored.
FACTOR(exp,p) factors exp over the field of integers with an
element adjoined whose minimum polynomial is p.
FACTORFLAG [TRUE] if FALSE supresses the factoring of
integers and integer factors of polynomials.
DONTFACTOR may be set to a list of variables with respect
to which factoring is not to occur. (It is initially empty).
Factoring also will not take place with respect to any
variables which are less important (using the variable
ordering assumed for CRE form) than those on the DONTFACTOR
list. (see sect. 7.6)
General Purpose Commands page 7.0-9
SAVEFACTORS [FALSE] if TRUE causes the factors of an ex-
pression which is a product of factors to be saved by certain
commands in order to speed up later factorizations of expres-
sions containing some of the same factors.
BERLEFACT [TRUE] if FALSE will cause the Kronecker
factoring algorithm to be employed while if it is TRUE then
the Berlekamp algorithm will be employed. [29] In most cases
the Berlekamp algorithm is to be preferred.
(C1) FACTOR(2**63-1);
2
(D1) 73 127 337 92737 649657 7
(C2) FACTOR(Z**2*(X+2*Y)-4*X-8*Y);
(D2) (2 Y + X) (Z - 2) (Z + 2)
(C3) X**2*Y**2+2*X*Y**2+Y**2-X**2-2*X-1;
2 2 2 2 2
(D3) X Y + 2 X Y + Y - X - 2 X - 1
(C4) DONTFACTOR:[X]$
(C5) FACTOR(D3);
2
(D5) (X + 2 X + 1) (Y - 1) (Y + 1)
(C6) FACTOR(%E**(3*X)+1);
X 2 X X
(D6) (%E + 1) (%E - %E + 1)
SQFR(exp) is similar to FACTOR except that the polynomial factors
are "square-free" that is, have no multiple roots. This
algorithm, which is also used by the first stage of FACTOR,
utilizes the fact that a polynomial has in common with its nth
derivative all its factors of degree > n. Thus by taking
derivatives with respect to each variable in the polynomial,
all factors of degree > 1 can be found. This command may also
be used on rational functions.
(C1) SQFR(4*X**4+4*X**3-3*X**2-4*X-1);
2 2
(D1) (X - 1) (2 X + 1)
General Purpose Commands page 7.0-10
GFACTOR(exp) factors the polynomial exp over the Gaussian integers
(i. e. with SQRT(-1) = %I adjoined)
(C1) GFACTOR(X**4-1);
(D1) (X - 1) (X + 1) (X + %I) (X - %I)
DIFF(exp,v1,n1,v2,n2,...) differentiates exp with respect to each
vi, ni times. If just the first derivative with respect to
one element is desired then the form DIFF(exp,v) may be used.
If the noun form is required (as, for example, when writing a
differential equation), 'DIFF should be used and this will
display in a two dimensional format. DIFF(exp) gives the
"total derivative", that is, the sum of the derivatives of exp
with respect to each of its variables times the function DEL
of the variable. No further simplification of DEL is offered
at this time.
DERIVATIVEABREV [FALSE] if TRUE will cause derivatives to
display as subscripts.
DERIVFLAG [FALSE] if TRUE will cause the differentiations
to be carried out when expressions containing noun forms of
the derivative are given to EV.
DEPENDENCIES(f1,...,fn) declares functional dependencies for atoms
to be used by DIFF. Each fi (i=1,n) has the format
f(v1,...,vm) where each vj (j=1,m) is a variable on which f
depends. Thus DIFF(Y,X) is 0, initially. Executing
DEPENDENCIES(Y(X)) causes future differentiations of Y with
respect to X to be displayed as
DY
--
DX
It is possible to give several levels of dependency
relations because MACSYMA knows the chainrule for symbolic
derivatives.
The variable DEPENDENCIES is a list of the functional
dependencies attributed to atoms by uses of the DEPENDENCIES
command. Each member of the list is of the form f(v1,..).
(C1) DEPENDENCIES(A(X));
(D1) [A]
(C2) DIFF(A.A,X);
DA DA
(D2) -- . A + A . --
DX DX
General Purpose Commands page 7.0-11
(C3) %,A=MATRIX([X,1/X],[X**2,1]),DIFF,MATMUL;
* 1 *
* 2 X + 1 - --*
* 2*
(D3) * X *
* *
* 2 *
*3 X + 2 X 1 *
(C4) DEPENDENCIES(F(X,Y),X(T),Y(T));
(D4) [F(X, Y), X(T), Y(T)]
(C5) DIFF(F,T);
DF DY DF DX
(D5) -- -- + -- --
DY DT DX DT
GRADEF(f(x1,...,xn),g1(x1),...,gn(xn)) defines the derivatives of
the function f with respect to its n arguments. That is,
df/dx1 = g1(x1), etc. The xi are merely dummy variables which
indicate the derivative with respect to the ith argument.
This command should not be confused with the DEPENDENCIES
command as the two are mutually exclusive.
Gradients are needed when, for example, a function is not
known explicitly but its first derivatives are and it is
desired to obtain higher order derivatives. GRADEF may also
be used to redefine the derivatives of MACSYMA's predefined
functions (e.g. GRADEF(SIN(X),SQRT(1-SIN(X)**2)) ). It is
not permissible to use GRADEF on subscripted functions.
GRADEFS is a list of the functions which have been given
gradients by use of the GRADEF command.
(C1) DEPENDENCIES(Y(X))$
(C2) GRADEF(F(X,Y),X**2,G(X,Y))$
(C3) DIFF(F(X,Y),X);
DY 2
(D3) G(X, Y) -- + X
DX
(C4) GRADEF(J(N,Z),'DIFF(J(N,Z),N),
J(N-1,Z)-N/Z*J(N,Z))$
(C5) DIFF(J(2,X),X,2)$
General Purpose Commands page 7.0-12
(C6) RATSIMP(%);
2
J(0, X) X - 3 J(1, X) X + 6 J(2, X)
(D6) ------------------------------------
2
X
(The example above computes the second derivate of a Bessel
function of order two.)
INTEGRATE(exp,var) integrates exp with respect to var or returns
an integral expression (the noun form) if it cannot perform
the integration.
INTEGRATE(exp,var,low,high) finds the definite integral of exp
with respect to var from low to high. The limits should not
contain var. Several methods are used, including direct
substitution in the indefinite integral and contour
integration. Improper integrals may use the names INF for
positive infinity and MINF for negative infinity. If an
integral "form" is desired for manipulation (for example, an
integral which cannot be computed until some numbers are
substituted for some parameters), the noun form 'INTEGRATE may
be used and this will display with an integral sign.
Sometimes during definite integration the user may be
asked what the sign of an expression is. Suitable responses
are POS; , ZERO; , or NEG; . (see also sect. 7.12)
(C1) INTEGRATE(SIN(X)**3,X);
3
COS (X)
(D1) ------- - COS(X)
3
(C2) INTEGRATE(X**A/(X+1)**(5/2),X,0,INF);
IS A + 1 POSITIVE, NEGATIVE, OR ZERO?
POS;
IS 2 A - 3 POSITIVE, NEGATIVE, OR ZERO?
NEG;
3
(D2) BETA(A + 1, - - A)
2
(C3) GRADEF(ERF(X),%E**(-X**2))$
General Purpose Commands page 7.0-13
(C4) DIFF(LOG(ERF(G(X))),X);
D
-- G(X)
DX
(D4) -----------------
2
G(X)
%E ERF(G(X))
(C5) INTEGRATE(%,X);
(D5) LOG(ERF(G(X)))
RISCH(exp,var) integrate exp with respect to var using the Risch
algorithm. This handles certain cases of nested exponentials
and logarithms which INTEGRATE can't do.
(C1) %E**%E**X*(1+X*%E**X);
X
X %E
(D1) (X %E + 1) %E
(C2) RISCH(%,X);
X
%E
(D2) X %E
SUM(exp,ind,lo,hi) performs a summation of the values of exp as
the index ind varies from lo to hi. If the summation cannot
be performed, or if 'SUM is used, the value is a sum noun form
which is a representation of the sigma notation used in mathe-
matics.
CAUCHYSUM [FALSE] when TRUE causes the Cauchy product to
be used when multiplying sums together rather than the usual
product. In the Cauchy product the index of the inner
summation is a function of the index of the outer one rather
than varying independently.
GENINDEX [I] is the alphabetic prefix used to generate a
variable of summation.
DOSUM [TRUE] if TRUE causes an actual addition of terms
of the sum if the difference between the upper and lower
limits is an integer. If it is not or if DOSUM is FALSE then
the setting of the variable SIMPSUM (see below) will govern
summation.
SIMPSUM [TRUE] if TRUE will cause SUM to try to produce a
closed form expression for the sum using the limits of summa-
tion. If a closed form can't be found or if SIMPSUM is FALSE
then the noun form will be returned.
OUTSUM [FALSE] if TRUE will causes factors of the summand
General Purpose Commands page 7.0-14
which don't depend upon the index of summation to be moved
outside of the sum.
(C2) SUM(I**2+2**I,I,0,N);
3 2
N + 1 2 N + 3 N + N
(D2) 2 + --------------- - 1
6
(C3) SUM(3**(-I),I,1,INF);
1
(D3) -
2
(C4) SUM(1/I,I,1,4)*SUM(F(I*I),I,1,N);
N
\==== 2
\ 25 F(I )
(D4) > --------
/ 12
/====
I = 1
Sums may be differentiated, added, subtracted, or
multiplied with some automatic simplification being performed.
PRODUCT(exp,ind,lo,hi) performs a product of the values of exp as
the index ind varies from lo to hi.
(C1) PRODUCT(X+I*(I+1)/2,I,1,4);
(D1) (X + 1) (X + 3) (X + 6) (X + 10)
General Purpose Commands page 7.0-15
MACSYMA Special Variables
Affecting General Simplification
%EMODE [FALSE] - when TRUE some exponentials involving complex
numbers ( like %E**(%PI*%I) ) are simplified, otherwise (the
default) they are not.
LOGSIMPOFF [FALSE] - if TRUE then simplification of forms like
%E**LOG(X) is inhibited.
EXPONENTIALIZE [FALSE] - if TRUE will cause all trigonometic and
hyperbolic functions to be converted to exponential form.
BRANCH [FALSE] - if TRUE will produce the principal branch of an
expression, i.e. it will cause %I**(C/D) to be converted to
%E**(%PI*%I*C/(2*D)) and (-A/B)**(C/D) to be converted to
(A/B)**(C/D)*%E**(%PI*%I*C/D).
RATSIMPEXPONS [FALSE] - if TRUE will cause exponents to be
RATSIMPed (see RATSIMP command below).
EXPON [0] - the exponent of the largest negative power which is
automatically expanded (independent of calls to EXPAND). For
example if EXPON is 4 then (X+1)**(-5) will not be
automatically expanded.
EXPOP [0] - the highest positive exponent which is automatically
expanded. Thus (X+1)**3, when typed, will be automatically
expanded only if EXPOP is greater than or equal to 3. If it
is desired to have (X+1)**N expanded where N is greater than
EXPOP then executing EXPAND((X+1)**N) will work only if N is
less than or equal to MAXPOSEX.
FACTLIM [-1] the highest factorial or GAMMA function to be
evaluated automatically. If -1 all factorials are evaluated.
TRIGSIGN [TRUE] - if TRUE permits simplification of negative argu-
ments to trigonometric functions. That is, SIN(-X) will become
-SIN(X) only if TRIGSIGN is TRUE.
TRIGEXPAND [FALSE] - if TRUE will cause SINs and COSs of sums or
of multiple angles to be automatically expanded.
Part Selection Commands page 7.1-1
7.2 Part Selection and Substitution
The commands in this section are used to extract or
replace parts of expressions.
The Part Commands
The part commands make it possible to reference or
replace any part of any MACSYMA expression. A part is
referred to by a set of indices which are non-negative
integers. For example, in exponentiation the base is
considered part 1 and the exponent part 2. In a quotient the
numerator is part 1 and the denominator part 2. In a sum or
product the ith term or factor is part i. In any expression
the main operator is part 0. Note that unary minus is
considered an operator.
In order to use the part selection commands it is
necessary to understand how expressions are ordered. When an
expression is input to MACSYMA the parsing program translates
it into LISP and the result is the value of the current C line
with the input order preserved. Subsequently the expression
is evaluated (except for function definitions) and the result
is simplified (see sect. 4.0). The simplifier re-orders
expressions in order to obtain a standard form and the result
(called the "internal form") is the value of the current D
line. Thus A+B+C or C+A+B or C+B+A if input, will all result
in the same internal form namely (PLUS A B C). The inpart
commands (INPART, SUBSTINPART, and FIRST, REST, and LAST with
INFLAG set to TRUE - see below) deal with this internal form.
However the display program formats the expression before
outputting it and this formatting process causes re-ordering
among other changes. The most noticable effect is that sums
display with terms in an order which is the reverse of that in
the internal form. The part commands (PART, DPART, and
SUBSTPART) format their arguments also and thus refer to the
parts of the expression as it would be displayed.
Certain commands (e.g. SUBST, COEFF, etc.) do not
reference parts of an expression by a set of indices.
Instead, an argument to these commands is the explicit part of
the expression referenced. For example, X is a part of the
expression 2*X**2+A. In some of these commands however, if
the part is not an atom then it must be a complete
subexpression of the referenced expression. That is, in the
LISP internal representation (see 4.0), the part must
explicitly appear. For example X*Y is not a complete
subexpression of 2*X*Y because (PLUS X Y) does not occur as an
explicit part of (PLUS 2 X Y).
Part Selection Commands page 7.1-2
PART(exp,n1,...,nk) obtains the part of exp as specified by the
indices n1,...,nk. First part n1 of exp is obtained, then
part n2 of that, etc. The result is part nk of ... part n2 of
part n1 of exp. Thus PART(Z+2*Y,2,1) yields 2. PART(X+Y,0)
yields +; however, in order to refer to the operator it must
be enclosed in "s. For example ...IF PART(D9,0)="+" THEN ...
PART can be used to obtain an element of a list, a row of
a matrix, etc.
(C1) X+Y/Z**2;
Y
(D1) -- + X
2
Z
(C2) PART(D1,1,2,2);
(D2) 2
(C3) 'INTEGRATE(F(X),X,A,B);
B
/
[
(D3) I F(X)DX
]
/
A
(C4) PART(%,1);
(D4) F(X)
INPART(exp,n1,...,nk) is similar to PART but works on the internal
representation of the expression rather than the displayed
form and is thus faster. Care should be taken with respect to
the order of subexpressions in sums and products (since the
order of variables in the internal form is often different
from that in the displayed form) and in dealing with unary
minus and division (since these are converted to multiplica-
tion by a minus one and by the denominator raised to the minus
one power respectively). The first example below illustrates
one difference between INPART and PART.
(C1) X+Y+W*Z;
(D1) W Z + Y + X
(C2) INPART(D1,3,2);
(D2) Z
(C3) PART(D1,1,2);
Part Selection Commands page 7.1-3
(D3) Z
(C4) INPART(X*%E**X,2,0);
(D4) **
DPART(exp,n1,...,nk) selects the same subexpression as PART, but
instead of just returning that subexpression as its value, it
returns the whole expression with the selected subexpression
displayed inside a box. The box is actually part of the
expression.
(C1) DPART(X+Y/Z**2,1,2,1);
Y
(D1) ---- + X
2
*****
* Z *
*****
UNBOX(expr) removes any boxes placed on expr by DPART.
Substitution Commands
SUBST(a,b,c) substitutes a for b in c. b must be an atom, or a
complete subexpression of c. For example, X+Y+Z is a complete
subexpression of 2*(X+Y+Z)/W while X+Y is not. When b does
not have these characteristics, one may sometimes use
SUBSTPART or RATSUBST (see below). a and b may also be
operators of an expression enclosed in "s or they may be
function names.
SUBST(eq1,exp) or SUBST([eq1,...,eqk],exp) are other permissible
forms. The eqi are equations indicating substitutions to be
made. For each equation, the right side will be substituted
for the left in the expression exp. Note that EV(c,b=a) does
not always produce the same result as SUBST(a,b,c) as the
former doesn't evaluate b and it does a binding if b is atomic
whereas the latter evaluates b and always does a substitution.
EXPTSUBST [FALSE] if TRUE permits substitutions like Y
for %E**X in %E**(A*X) to take place.
(C1) SUBST(A,X+Y,X+(X+Y)**2+Y);
2
(D1) Y + X + A
(C2) SUBST(-%I,%I,A+B*%I);
(D2) A - %I B
Part Selection Commands page 7.1-4
(Note that this is one way of obtaining
the complex conjugate of an expression.)
(C3) A+B*%I,%I=-%I;
%I IMPROPER VALUE ASSIGNMENT
(C4) SUBST(X=0,DIFF(SIN(X),X));
(D4) 1
(C5) DIFF(SIN(X),X),X=0;
0
ATTEMPT TO DIFFERENTIATE WRT A NUMBER
(C6) MAT([A,B],[C,D])*[A,D]$
(C7) SUBST(["*" = ".",MAT=MATRIX],%);
*A B*
(D7) [A, D] . * *
*C D*
(Note the use of SUBST here to change a function name. This
is one way to correct misspelling of functions.)
RATSUBST(a,b,c) substitutes a for b in c. b may be a sum,
product, power, etc. RATSUBST knows something of the meaning
of expressions whereas SUBST does a purely syntactic substitu-
tion. Thus SUBST(A,X+Y,X+Y+Z) returns X+Y+Z whereas RATSUBST
would return Z+A.
(C1) RATSUBST(A,X*Y**2,X**4*Y**8+X**4*Y**3)
3 4
(D1) A X Y + A
SUBSTPART(x,exp,n1,...,nk) substitutes x for the subexpression
picked out by the rest of the arguments as in PART. It
returns the new value of exp. x may be any expression
including an operator of exp. In this case it is enclosed in
"s.
(C1) 1/(X**2+2);
1
(D1) ------
2
X + 2
Part Selection Commands page 7.1-5
(C2) SUBSTPART(3/2,%,2,1,2);
1
(D2) --------
3/2
X + 2
SUBSTINPART(x,exp,n1,...) is like SUBSTPART but works on the
internal representation of exp.
(C1) SUBSTINPART(?+?,A*B*C,0);
(D1) C + B + A
Additional Information
If the last argument to a part command is a list of indices
then several subexpressions are picked out, each one
corresponding to an index of the list. Thus PART(X+Y+Z,[1,3])
is X+Z.
PIECE holds the value of the last expression selected when
using the part commands. It is set during the execution of
the command and thus may be referred to in the command itself
as shown below.
If PARTSWITCH [FALSE] is set to TRUE then END is returned when
a selected part of an expression falls off the end, otherwise
an error message is given.
(C1) 27*Y**3+54*X*Y**2+36*X**2*Y+Y+8*X**3+X+1;
3 2 2 3
(D1) 27 Y + 54 X Y + 36 X Y + Y + 8 X + X + 1
(C2) PART(D1,2,[1,3]);
2
(D2) 54 Y
(C3) SQRT(PIECE/54);
(D3) Y
(C4) SUBSTPART(FACTOR(PIECE),D1,[1,2,3,5]);
3
(D4) (3 Y + 2 X) + Y + X + 1
Part Selection Commands page 7.1-6
Other Commands for Extracting Parts of Expressions
COEFF(exp,v,n) obtains the coefficient of v**n in exp. n may be
omitted if it is 1. v may be an atom, or complete subexpres-
sion of exp e.g., X, SIN(X), A[I+1], X+Y, etc. (In the last
case the expression (X+Y) should occur in exp). Sometimes it
may be necessary to expand exp. This is not done automati-
cally be COEFF.
(C1) COEFF(2*A*TAN(X)+TAN(X)+B=5*TAN(X)+3,TAN(X));
(D1) 2 A + 1 = 5
(C2) COEFF(Y+X*%E**X+1,X,0);
(D2) Y + 1
RATCOEF(exp,part,n) returns the coefficient, C, of the expression
(part)**n in the expression exp. n may be omitted if it is 1.
C will be free (except possibly in a non-rational sense) of
the variables in part. If no coefficient of this type exists,
zero will be returned. RATCOEF expands and rationally
simplifies its first argument and thus it may produce answers
different from those of COEFF which is purely syntactic. Thus
RATCOEF((X+1)/Y+X,X) returns (Y+1)/Y whereas COEFF returns 1.
RATCOEF(exp,part,0) is currently the same as
RATSUBST(0,part,exp). This won't work if part occurs to any
negative powers. Since exp is rationally simplified before it
is examined, coefficients may not appear quite the way they
were envisioned.
(C1) S:A*B*X**2+B*X+2*X+5;
2
(D1) A B X + B X + 2 X + 5
(C2) RATCOEF(S,B);
2
(D2) A X + X
NUMFACTOR(exp) gives the numerical factor multiplying the expres-
sion exp.
Part Selection Commands page 7.1-7
(C1) GAMMA(7/2);
(D1) 15 SQRT(%PI)
------------
8
(C2) NUMFACTOR(%)
15
(D2) --
8
HIPOW(expr,v) the highest exponent of the v in expr. Sometimes it
may be necessary to expand expr since tthis is not done
automatically by HIPOW. Thus HIPOW(Y**3*X**2+X*Y**4,X) is 2.
LOPOW(expr,v) the lowest exponent of v which explicitly appears in
expr. Thus LOPOW((X+Y)**2+(X+Y)**A,X+Y) is MIN(A,2).
DERIVDEGREE(expr,iv,dv) finds the highest degree of the derivative
of the independent variable iv with respect to the dependent
variable dv occuring in expr.
(C1) 'DIFF(Y,X,2)+'DIFF(Y,Z,3)*2+'DIFF(Y,X)*X**2$
(C2) DERIVDEGREE(%,Y,X);
(D2) 2
IMAGPART(exp) the imaginary part of the expression exp.
REALPART(exp) the real part of exp. IMAGPART and REALPART will
work on expressions involving trigonometic and hyperbolic
functions, as well as SQRT, LOG, and exponentiation.
(C1) SEPARATE(Z):=REALPART(Z)+%I*IMAGPART(Z)$
(C2) SEPARATE(SIN(2*%I+X));
(D2) COSH(2) SIN(X) + %I SINH(2) COS(X)
(C3) SEPARATE(LOG(3+4*%I));
4
(D3) LOG(5) + %I ATAN(-)
3
(C4) SEPARATE((2+3.5*%I)↑.25),NUMER,EVAL,RATPRINT=FALSE;
(D4) 0.36825881 %I + 1.3682663
(C5) %↑4,EXPAND;
(D5) 3.5 %I + 2.0
Part Selection Commands page 7.1-8
LHS(eqn) the left side of the equation eqn.
RHS(eqn) the right side of the equation eqn.
FIRST(exp) yields the first part of exp which may result in the
first element of a list, the first row of a matrix, the first
term of a sum, etc. Note that FIRST and the following two
commands work on the form of exp which is displayed not the
form which is typed on input. If the variable INFLAG [FALSE]
is set to TRUE however, these commands will look at the
internal form of exp which is the simplified input. Note that
the simplifier re-orders expressions. Thus FIRST(X+Y) will be
X if INFLAG is TRUE and Y if INFLAG is FALSE. (FIRST(Y+X)
will gives the same results of course).
REST(exp,n) yields exp with its first n elements removed if n is
positive and its last n elements removed if n is negative. If
n is 1 it may be omitted. exp may be a list, matrix, or other
expression.
LAST(exp) yields the last part (term, row, element, etc.) of the
exp.
DELETE(exp1,exp2) removes all occurrences of exp1 from exp2. exp1
may be a term of exp2 (if it is a sum) or a factor of exp2 (if
it is a product).
(C1) DELETE(SIN(X),X+SIN(X)+Y);
(D1) Y + X
LENGTH(exp) gives the number of elements in a list, the number of
rows of a matrix, the number of terms in a sum, etc.
SOLVE Commands page 7.3-1
7.3 SOLVE and Related Commands
The following commands obtain the roots of equations or
yield information concerning the roots.
NROOTS(poly,low,high) finds the number of realroots of the real
univariate polynomial poly between the limits of low and high
which may be MINF and INF respectively for minus infinity to
plus infinity. The method of Sturm sequences is used.
(C1) POLY1:X**10-2*X**4+.5$
(C2) NROOTS(POLY1,-6,9.1);
RAT REPLACED 0.5 BY 1/2 = 0.5
(D2) 4
REALROOTS(poly,bound) finds all of the real roots of the real uni-
variate polynomial poly within a tolerance of bound which, if
less than 1, causes all integral roots to be found exactly.
bound may be arbitrarily small in order to achieve any desired
accuracy (if less than RATEPSILON [2.E-8] it should be
rational).
(C1) REALROOTS(POLY1,5.0E-6)$
(C6) D5,FLOAT;
(D6) [X = - 1.0860043, X = - 0.71998405, X = 0.71998405,
X = 1.0860043]
(C7) POLY1,X=1.086;
(D7) - 4.1246414E-5
ALLROOTS(expr) finds all the real and complex roots of the real
polynomial expr which must be in one variable and may be an
equation. The Newton-Bairstow is used. After a root is
located approximately from the reduced polynomial it is
refined using the original polynomial. If convergence can't
be obtained the reduced polynomial is returned. A better
algorithm is forthcoming.
(C1) (2*X+1)↑3=13.5*(X↑5+1);
3 5
(D1) (2 X + 1) = 13.5 (X + 1)
(C2) ALLROOTS(%);
(E2) X = - 1.0157555
SOLVE Commands page 7.3-2
(E3) X = 0.829675
(E4) X = - 0.96596254 %I - 0.40695972
(E5) X = 0.96596254 %I - 0.40695972
(E6) X = 1.0
(D6) [E2, E3, E4, E5, E6]
LINSOLVE(eqns,vars) solves the list of simultaneous linear
equations eqns for the list of variables vars.
Although the SOLVE command does this also, LINSOLVE is
faster since SOLVE takes time to determine the fact that the
equations are linear, whereas LINSOLVE assumes this to be
true.
BACKSUBSTOFF [FALSE] if set to TRUE will prevent back
substitution after the equations have been triangularized.
This may be necessary in very big problems where back substi-
tution would cause the storage capacity to be exceeded.
ALGSYS([eq1,eq2,...],[var1,var2,...]) solves the list of
simultaneous non-linear equations for the list of variables.
SOLVE can also do this but again, as in the linear case, it
takes added time to determine this fact. The eqi are
expressions assumed to be equal to zero rather than actual
equations containing an equal sign.
SOLVE(exp,var) solves the algebraic equation exp for the variable
var. If exp is not an equation, it is assumed to be an ex-
pression to be set equal to zero. Var may be a function (e.g.
F(X)), or other non-atomic expression except a sum or product.
It may be omitted if exp contains only one variable. Exp may
be a rational function, and may contain trigonometric
functions, exponentials, etc.
SOLVE([eq1,...,eqn],[v1,...,vn]) solves a system of simultaneous
(linear or non-linear) algebraic equations. It takes two
lists as arguments. The first list (eqi, i=1,...,n) repre-
sents the equations to be solved; the second list is a list of
the unknowns to be determined. If the total number of
variables in the equations is equal to the number of equa-
tions, the second argument-list may be omitted. If there are
more variables than equations, in the non-linear case, the
user will be given the opportunity to substitute numerical
values for some of the variables, to solve the equations in
terms of the extra variables, or to obtain a reduced system of
SOLVE Commands page 7.3-3
equations. The reduced systems can be solved later using the
command BAKSOLVE (see below). However if the variable
GRINDSWITCH [FALSE] is TRUE then an attempt will be made to
solve for the given variables even if there are undetermined
parameters in the system.
If the given equations are not compatible, the message
INCONSISTENT will be displayed. If no unique solution exists,
SINGULAR will be displayed. In some cases where a solution
cannot be obtained a reduced system of polynomials is returned
with some variables eliminated. The solution is exact
assuming the user has not used floating-point numbers in his
input, and may involve symbolic variables. The solution set
consists of a list of numbered equations and an index to the
list.
If GLOBALSOLVE [FALSE] is set to TRUE then variables
which are SOLVEd for will be set to the solution of the set of
simultaneous equations. This switch applies to the LINSOLVE
command as well.
The success of SOLVE may depend partly on the setting of the
following switches.
SOLVEFACTORS [TRUE] - if FALSE then SOLVE will not try to
factor the expression. The FALSE setting may be desired in
some cases where factoring is not necessary.
SOLVERADCAN [FALSE]- if TRUE then SOLVE will use RADCAN
which will make SOLVE slower but will allow certain problems
containing exponentials and logs to be solved.
(C1) SOLVE(ASIN(COS(3*X))*(F(X)-1),X);
SOLUTION
%PI
(E1) X = ---
6
THE ROOTS OF
(E2) F(X) = 1
(D2) [E1, E2]
(C3) SOLVERADCAN:TRUE$
(C4) SOLVE(5**F(X)=125,F(X));
(D4) F(X) = 3
(C5) [4*X**2-Y**2=12,X*Y-X=2]
2 2
(D5) [4 X - Y = 12, X Y - X = 2]
SOLVE Commands page 7.3-4
(C6) SOLVE(D5,[X,Y]);
(D6) [[Y = - 0.15356758, X = - 1.733752],
[Y = 2.0, X = 2.0]]
BAKSOLVE(eqlist,varlist) solves a reduced system of equations such
as that sometimes returned by SOLVE. eqlist is a list of
lists of equations, n in the first list, n-1 in the second,...
varlist is a list of variables to be solved for. The last
equation in eqlist is solved, and then the next to last is
reduced and solved, etc.
Matrix Commands page 7.4-1
7.4 The Matrix Commands
ENTERMATRIX(m,n) allows one to enter a matrix element by element
with MACSYMA requesting values for each of the m*n entries.
(C1) ENTERMATRIX(2,1);
ROW 1 COLUMN 1 X+Y/2;
ROW 2 COLUMN 1 34;
MATRIX-ENTERED
* Y *
* - + X *
(D1) * 2 *
* *
* 34 *
MATRIX (row1,...,rown) defines a rectangular matrix with the
indicated rows. Each row has the form of a list of expres-
sions, e.g. [A, X**2, Y, 0] is a list of 4 elements.
GENMATRIX(array,dim1,dim2) generates a matrix of dimension dim1 by
dim2 from the array.
(C1) H[I,J]:=1/(I+J-1)$
(C2) GENMATRIX(H,3,3);
* 1 1*
*1 - -*
* 2 3*
* *
*1 1 1*
(D2) *- - -*
*2 3 4*
* *
*1 1 1*
*- - -*
*3 4 5*
COPYMATRIX(M) creates a copy of the matrix M. This is the only
way to make a copy aside from recreating M elementwise.
Copying a matrix may be useful when SETELMX is used (see
below).
ADDROW(M,l) appends the row given by the list l onto the matrix M.
Matrix Commands page 7.4-2
IDENT(n) produces an n by n identity matrix.
DIAGMATRIX(n,x) returns a diagonal matrix of size n by n with the
diagonal elements all x. An identity matrix is created by
DIAGMATRIX(n,1), or one may use IDENT(n).
EMATRIX(m,n,x,i,j) will create an m by n matrix all of whose ele-
ments are zero except for the i,j element which is x.
SETELMX(x,i,j,M) changes the i,j element of M to x. The altered
matrix is returned as the value. The notation M[i,j]:x may
also be used, altering M in a similar manner, but returning x
as the value.
COEFMATRIX([eq1,...],[var1,...]) the coefficient matrix for the
variables var1,... of the system of linear equations eq1,...
AUGCOEFMATRIX([eq1,...,eqn],[var1,...,vark]) the augmented coef-
ficient matrix for the variables var1,...,vark of the system
of linear equations eq1,...,eqn. This is the coefficient
matrix with a column adjoined for the constant terms in each
equation (i.e. those not dependent upon var1,...).
(C1) [2*X-(A-1)*Y=5*B,A*X+B*Y+C=0]$
(C2) AUGCOEFMATRIX(%,[X,Y]);
*2 1 - A 5 B *
(D2) * *
*A B - C*
COL(M,i) the ith column of the matrix M.
ROW(M,i) the ith row of matrix M.
SUBMATRIX(m1,..., M, n1,...) creates a new matrix composed of the
matrix M with rows mi deleted, and columns ni deleted.
MINOR(M,i,j) computes the i,j minor of the matrix M. That is, M
with row i and column j removed.
TRANSPOSE(M) produces the transpose of M.
ECHELON(M) produces the echelon form of M. That is, M with ele-
mentary row operations performed on it such that the first
non-zero element in each row in the resulting matrix is a one
and the column elements under the first one in each row are
all zero.
Matrix Commands page 7.4-3
(C3) ECHELON(D2);
(D2 is as above)
* A - 1 5 B *
*1 - ----- --- *
* 2 2 *
(D3) * *
* 2 C + 5 A B *
*0 1 - ------------*
* 2 *
* 2 B + A - A*
TRIANGULARIZE(M) produces the upper triangular form of the matrix
M which needn't be square.
(C4) TRIANGULARIZE(D2);
*2 - A + 1 5 B *
(D4) * *
* 2 *
*0 2 B + A - A - 2 C - 5 A B*
RANK(M) computes the rank of the matrix M. That is, the order of
the largest non-singular subdeterminant of M.
(C5) RANK(D2);
(D5) 2
DETERMINANT(M) computes the determinant of M.
CHARPOLY(M,var) computes the characteristic polynomial for M with
respect to var.
That is, DETERMINANT(M - DIAGMATRIX(LENGTH(M),var)).
(C2) A:MATRIX([3,1],[2,4]);
*3 1*
(D2) * *
*2 4*
(C3) CHARPOLY(A,LAMBDA);
2
(D3) LAMBDA - 7 LAMBDA + 10
(C4) SOLVE(%);
SOLUTION
Matrix Commands page 7.4-4
(E4) LAMBDA = 2
(E5) LAMBDA = 5
(D5) [E4, E5]
(C6) X:MATRIX([X1],[X2]);
*X1*
(D6) * *
*X2*
(C7) A*X-LAMBDA*X,E5,EXPAND;
* X2 - 2 X1 *
(D7) * *
* - X2 + 2 X1*
(C8) D7[1,1]=0;
(D8) X2 - 2 X1 = 0
(C9) X1**2+X2**2=1;
2 2
(D9) X2 + X1 = 1
(C10) SOLVE([D8,D9],[X1,X2]);
(D10) [[X2 = - 0.89442714, X1 = - 0.44721357],
[X2 = 0.89442714, X1 = 0.44721357]]
MATRIXMAP(function,matrix) will apply the function to each element
of the matrix and return the resulting matrix. The function
may be either the name of an existing function or the form
LAMBDA([var],expr) where var is some variable not appearing in
the matrix that is used in the expression to stand for
successive elements of the matrix. The LAMBDA form is needed
whenever it is desired to map a function of more than one
argument. For example MATRIXMAP(LAMBDA([V],V+1),M) results in
a matrix each of whose elements is one more than the
corresponding element of the matrix M.
(C4) MATRIX([X+1/X,0],[0,X/(X-1)-1]);
* 1 *
*X + - 0 *
* X *
(D4) * *
* X *
* 0 ----- - 1*
* X - 1 *
Matrix Commands page 7.4-5
(C5) MATRIXMAP(RATSIMP,%);
* 2 *
*X + 1 *
*------ 0 *
(D5) * X *
* *
* 1 *
* 0 -----*
* X - 1*
Special Variables Relating to Matrices
SCALARMATRIX [FALSE] - if TRUE will cause scalars to be kept
outside of matrices even if they are EXPANDed.
DETOUT [FALSE] - if TRUE will cause the determinant of a
matrix whose inverse is computed to be kept outside of the
inverse.
MATMUL [FALSE] - if TRUE will cause matrix multiplication
using the non-commutative product operator to take place.
NORAT [FALSE] - if TRUE will cause matrix addition,
subtraction, and multiplication to be performed in general
representation on matrix elements. The default is to do these
operations on the CRE form of the matrix elements for
efficiency reasons; however, sometimes the user may not want
matrix elements converted to CRE form (see section 7.6).
Other General Purpose Commands page 7.5-1
7.5 Other General Purpose Commands
This section contains commands which are related to but
are less frequently used than those in 7.1, e.g. those dealing
with series, continued fractions, direct and inverse Laplace
transforms, etc.
LIMIT(exp,var,val,dir) finds the limit of exp as the real variable
var approaches the value val from the direction dir. Dir may
have the value PLUS for a limit from above, MINUS for a limit
from below, or may be omitted (implying a two-sided limit is
to be computed). LIMIT uses the following special symbols:
INF (positive infinity) and MINF (negative infinity). On
output it may also use UND (undefined), IND (indefinite but
bounded) and INFINITY (complex infinity). 'LIMIT may be used
to simply create a limit noun form and this will display in a
two-dimensional form.
LHOSPITALLIM [4] is the maximum number of times the
L'HOSPITAL rule is used in LIMIT. This prevents infinite
looping in cases like LIMIT(COT(X)/CSC(X),X,0).
(C1) LIMIT(X*LOG(X),X,0,PLUS);
(D1) 0
(C2) LIMIT((1+X)**(1/X),X,0);
(D2) %E
(C3) LIMIT(%E**X/X,X,INF);
(d3) INF
(C4) LIMIT(SIN(1/X),X,0);
(D4) IND
RESIDUE(exp,var,val,order) computes the residue in the complex
plane of the expression exp when the variable var assumes the
value val. The expression is assumed to have a pole of the
given order at var=val. The residue is the coefficient of
(var-val)**(-1) in the Laurent series for exp.
(C1) RESIDUE(S/(S**2+A**2),S,A*%I,1);
1
(D1) -
2
Other General Purpose Commands page 7.5-2
(C2) RESIDUE(SIN(A*X)/X**4,X,0,4);
3
A
(D2) - --
6
LAPLACE(expr,ovar,lvar) takes the Laplace transform of expr with
respect to the variable ovar and transform parameter lvar.
expr may only involve the functions EXP, LOG, SIN, COS, SINH,
and COSH. It may also be a linear or non-linear differential
equation in which case the dependent variable might appear
subscripted in the transform in order to represent its value
and the value of its derivatives at zero. The notation Y[i]
is used to stand for the ith derivative of Y(ovar) at ovar=0.
If the dependent variable is not atomic as for example when
taking two transforms of a partial differential equation, then
the value of the variable LTRANSNAME [F] with subscripts, will
be used to represent the initial values. expr may also
involve convolution integrals. Functional relationships must
be explicitly represented in order for LAPLACE to work
properly. That is, if F depends on X and Y it must be written
as F(X,Y) wherever it occurs.
(C1) LAPLACE(%E**(2*T+A)*SIN(T)*T,T,S);
A
2 %E (S - 2)
(D1) ---------------
2 2
((S - 2) + 1)
ILT(exp,lvar,ovar) takes the inverse Laplace transform of exp with
respect to lvar and parameter ovar. exp must be a ratio of
polynomials whose denominator has only linear and quadratic
factors. By using the commands LAPLACE and ILT together with
the SOLVE or LINSOLVE commands the user can solve a single
differential or convolution integral equation or a set of
them.
Other General Purpose Commands page 7.5-3
(C1) 'INTEGRATE(SINH(A*X)*F(T-X),X,0,T)+B*F(T)=T**2;
T
/
[ 2
(D1) I (SINH(A X) F(T - X)) DX + B F(T) = T
]
/
0
(C2) LAPLACE(%,T,S);
1 1
(D2) B LAPLACE(F(T), T, S) + (--------- - ---------)
2 (S - A) 2 (S + A)
2
LAPLACE(F(T), T, S) = --
3
S
(C3) LINSOLVE([%],['LAPLACE(F(T),T,S)]);
SOLUTION
2 2
2 S - 2 A
(E3) LAPLACE(F(T), T, S) = --------------------
5 2 3
B S + (A - A B) S
(D3) [E3]
Other General Purpose Commands page 7.5-4
(C4) ILT(E3,S,T);
IS A B (A B - 1) POSITIVE, NEGATIVE, OR ZERO?
POS;
2
SQRT(A) SQRT(A B - B) T
2 COSH(------------------------) 2
B A T
(D4) F(T) = - -------------------------------- + -------
A A B - 1
2
+ ------------------
3 2 2
A B - 2 A B + A
POWERSERIES(exp,var,pt) generates the general form of the power
series expansion for exp in the variable var about the point
pt (which may be INF for infinity). In cases in which
POWERSERIES is unable to expand exp (such as with composition
of functions) the TAYLOR command (see below) will give the
first several terms of the series.
(C1) POWERSERIES(SIN(1/X),X,INF);
INF
\==== I1 - 2 I1 - 1
\ ( - 1) X
(D1) > ---------------------
/ (2 I1 + 1)!
/====
I1 = 0
TAYLOR(exp,var,pt,pow) expands the expression exp in a truncated
Taylor series (or Laurent series, if required) in the variable
var around the point pt. The terms through (var-pt)**pow are
generated.
If exp is of the form f(var)/g(var) and g(var) has only 0
terms up to degree pow then TAYLOR will try to expand g(var)
up to degree 2*pow. If there are still no non-zero terms
TAYLOR will keep doubling the degree of the expansion of
g(var) until reaching pow*2**n where n is the value of the
variable TAYLORDEPTH [default value 3].
Other General Purpose Commands page 7.5-5
(C1) TAYLOR(SQRT(1+A*X+SIN(X)),X,0,3);
2 2
(A + 1) X (A + 2 A + 1) X
(D1) 1 + --------- - -----------------
2 8
3 2 3
(3 A + 9 A + 9 A - 1) X
+ -------------------------- + . . .
48
(C2) %**2;
3
X
(D2) 1 + (A + 1) X - -- + . . .
6
(C3) PRODUCT((X**I+1)**2.5,I,1,INF)/(X**2+1);
INF
/===\
! ! I 2.5
! ! (X + 1)
! !
! !
I = 1
(D3) -----------------
2
X + 1
(C4) TAYLOR(%,X,0,3);
2 3
(D4) 1.0 + 2.5 X + 3.375 X + 7.25 X + . . .
DEFTAYLOR(function,exp) allows the user to define the taylor
series of an arbitrary function of one variable as exp which
may be a polynomial in that variable or which may be given
implicitly as a power series using the SUM command.
(C1) DEFTAYLOR(F(X),X**2+SUM(X**I/(2**I*I!**2),I,4,INF));
(D1) [F]
Other General Purpose Commands page 7.5-6
(C2) TAYLOR(%E**SQRT(F(X)),X,0,4);
2 3 4
X 3073 X 12817 X
(D2) 1 + X + -- + ------- + -------- + . . .
2 18432 307200
QUNIT(n) gives the principal unit element of the real quadratic
number field SQRT(n) where n is an integer, i.e. the element
whose norm is unity.
(C1) QUNIT(17);
(D1) SQRT(17)+4
(C2) EXPAND(%*(SQRT(17)-4));
(D2) 1
CF(exp) converts exp into a continued fraction. exp is an expres-
sion composed of arithmetic operators and lists which repre-
sent continued fractions. a+1/(b+1/(c+...)) is represented by
the list [a,b,c,...]. a,b,c,.. must be integers. exp may
also involve SQRT(n) where n is an integer. In this case CF
will give as many terms of the continued fraction as the value
of the variable CFLENGTH [1] times the period. Thus the
default is to give one period.
CFDISREP(list) converts the continued fraction represented by list
into standard MACSYMA representation.
(C1) CF([1,2,-3]+[1,-2,1]);
(D1) [1, 1, 1, 2]
(C2) CFDISREP(%);
1
(D2) 1 + ---------
1
1 + -----
1
1 + -
2
CFEXPAND(x) gives a matrix of the numerators and denominators of
the last and next-to-last convergents of the continued
fraction x.
(C1) CF(SQRT(3));
Other General Purpose Commands page 7.5-7
(D1) [1, 1, 2, 1, 2, 1, 2, 1]
(C2) CFEXPAND(%);
*71 97*
(D2) * *
*41 56*
(C3) D2[1,2]/D2[2,2],NUMER;
(D3) 1.7321429
BERNPOLY(X,N) generates the Nth Bernoulli polynomial in the
variable X.
TRIGEXPAND(exp,var) expands the SINs and COSs of sums and multiple
angles occuring in exp with respect to var or with respect to
all variables if var is omitted.
TRIGEXPAND [FALSE] if TRUE causes expansion of all expres-
sions containing SINs and COSs occurring subsequently.
(C1) X+SIN(3*X)/SIN(X),TRIGEXPAND=TRUE,EXPAND;
2 2
(D1) - SIN (X) + 3 COS (X) + X
(C2) TRIGEXPAND(SIN(10*X+Y),Y);
(D2) COS(10 X) SIN(Y) + SIN(10 X) COS(Y)
Rational Function Commands page 7.6-1
7.6 Rational Function Commands
A rational function is the quotient of two polynomials.
MACSYMA provides a special internal representation (called CRE
for canonical rational expression form) for rational functions
(and polynomials as special cases) which requires less storage
than the general representation. In addition CRE manipu-
lations are usually faster, therefore it is advisable to use
these whenever the problem of interest can be expressed
largely in terms of polynomials or rational functions. CRE
form is "contagious" in that any time a CRE expression is
added to or multiplied by another compatible expression, the
result is in CRE form. (see also sect. 4.0) Thus by
initially multiplying by RAT(1) one can force his entire
calculation to be done in CRE form.
RATVARS(var1,var2,...) orders the variables listed in its argument
list so that the rightmost element will be the main variable
of future rational expressions in which it occurs, and the
other variables will follow in sequence. If a variable is
missing from the RATVARS list, it will be given lower priority
than the leftmost element. The arguments to RATVARS can be
either variables or non-rational functions (e.g. SIN(X)). The
command PRINVARLIST() may be used to print the current
variable ordering.
RAT(exp,v1,...) converts exp to CRE form by expanding and
combining all terms over a common denominator and cancelling
out the greatest common divisor of the numerator and denom-
inator as well as converting floating point numbers to
rational numbers within a tolerance of RATEPSILON [2.0E-8].
The variables are ordered according to the v1,..., as in
RATVARS, if these are specified. RAT does not generally sim-
plify functions other than + , - , * , / , and exponentiation
to an integer power and it does not deal with equations
whereas RATSIMP does handle these cases.
RATPRINT [TRUE] if FALSE supresses the printout of the
message informing the user of the conversion of floating point
numbers to rational numbers.
KEEPFLOAT [FALSE] if TRUE will preventfloating point
numbers from being converted to rational numbers by making
them "new variables." Note however that simplification of
these floating point numbers will not be performed.
Rational Function Commands page 7.6-2
(C1) ((X-2*Y)**4/(X**2-4*Y**2)**2+1)*(Y+A)*(2*
Y+X)/(4*Y**2+X**2);
4
(X - 2 Y)
(Y + A) (2 Y + X) (------------ + 1)
2 2 2
(X - 4 Y )
(D1) ------------------------------------
2 2
4 Y + X
(C2) RAT(%,Y,A,X);
2 A + 2 Y
(D2) ---------
X + 2 Y
RATDISREP(EXP), which appears to do nothing on the command level,
changes its argument from rational function form (CRE) to
ordinary MACSYMA form. This is sometimes convenient if one
wishes to stop the "contagion", or use rational functions in
non-rational contexts (e.g. as arguments to SINH). Most CRE
commands will work on either CRE or non-CRE expressions, but
the answers may take different forms. If RATDISREP is not
given a CRE for an argument, it does nothing.
RATNUMER(exp) obtains the numerator of the rational expression
exp.
RATDENOM(exp) obtains the denominator of the rational expression
exp
GETVAR(exp) obtains the variable of the univariate polynomial exp.
DIVIDE(x,y,var) computes the quotient and remainder of the poly-
nomial x divided by the polynomial y, in a main polynomial
variable, var. The result is a list whose first element is
the quotient and whose second element is the remainder.
QUOTIENT(x,y,var) computes the quotient of the two polynomials x
and y with main variable var.
REMAINDER(x,y,var) computes the remainder of the polynomial x
divided by the polynomial y with main variable var.
** note: var may be omitted in DIVIDE, QUOTIENT, and REMAINDER
if X, and Y contain just one variable, or if they both have as
main variable the variable with respect to which the operation
is intended.
Rational Function Commands page 7.6-3
(C1) DIVIDE(X+Y,X-Y,X);
(D1) [1, 2 Y]
(C2) DIVIDE(X+Y,X-Y);
(D2) [ - 1, 2 X]
(Note that Y is the main variable in C2)
GCD(x,y) computes the greatest common divisor of x and y. The
EZGCD algorithm [31] will be employed unless the variable
EZOFFSWITCH [FALSE] is TRUE, in which case the setting of the
variable GCDSWITCH will govern which algorithm is to be used.
Many commands (e.g. RATSIMP, FACTOR, etc.) cause gcd's to be
taken implicitly. Thus care should be taken in the use of the
three gcd switches.
If GCDSWITCH [FALSE] is FALSE then the Collins reduced
prs algorithm is employed otherwise the modular algorithm is
employed. [5]
If GCDOFF [FALSE] is TRUE, MACSYMA takes all gcds to be
1.
CONTENT(expr,var) returns a list whose first element is the
greatest common divisor of the coefficients of the terms of
the polynomial expr in the variable var (this is the content)
and whose second element is the polynomial expr divided by the
content. If expr contains only one variable, or if the
content is desired with respect to the main variable, then var
may be omitted.
Thus CONTENT(2*X*Y+4*X**2*Y**2,Y) is [2*X , 2*X*Y**2+Y].
MOD(x) converts the polynomial x to a modular representation with
respect to the current integer modulus.
If MODULUS [FALSE] is set to a positive integer p, then
all arithmetic in the rational function routines will be done
modulo p.
RESULTANT(x,y,var) computes the resultant of the two polynomials x
and y, and eliminates the variable var. The resultant is a
determinant of the coefficients of var in x and y which equals
zero if and only if x and y have a non-constant factor in
common.
(C1) RESULTANT(A*Y+X**2+1,Y**2+X*Y+B,X);
4 3 2 2
(D1) Y + A Y + (2 B + 1) Y + B
RATDIFF(exp,var) differentiates the rational expression exp
(which must be a ratio of polynomials or a polynomial in the
Rational Function Commands page 7.6-4
variable var) with respect to var. For rational expressions
this is much faster than DIFF. The result is left in CRE
form.
(C1) (4*X**3+10*X-11)/(X**5+5);
3
4 X + 10 X - 11
(D1) ----------------
5
X + 5
(C2) MODULUS:3$
(C3) MOD(D1);
2
X + X - 1
(D3) --------------------
4 3 2
X + X + X + X + 1
(C4) RATDIFF(D1,X);
5 4 3
X - X - X + X - 1
(D4) ------------------------------
8 7 5 4 3
X - X + X - X + X - X + 1
7.6.1 Extended Rational Function Commands
An extended rational function may be a truncated
power series (such as that generated by TAYLOR) or a
generalization of CRE form expressions (see sect. 4.0).
ERAT(exp,var1,var2,...) will convert exp to extended rational
function form. The vars are variables which occur in exp
in order of increasing importance as with RAT.
ERATCANON [FALSE] if TRUE will cause the terms of
extended rational function expressions to be combined over
a common denominator if necessary to eliminate negative
exponents.
PS(exp,[v1,n1,v2,n2,...],[var1,var2,...]) converts exp to
extended rational function form ordering the variables
according to var1,... (if these are given) just as with
ERAT. In addition one can specify that variable vi is to
be truncated to the power ni.
PSEXPAND [FALSE] if TRUE will cause extended rational
Rational Function Commands page 7.6-5
function expressions to display fully expanded. (RATEXPAND
will also cause this. see 7.1)
SRRAT(exp) converts exp from extended rational form to CRE
form, i.e. it is like RAT(RATDISREP(exp)) although much
faster.
Type Testing Commands page 7.7-1
7.7 Type Testing
The type testing commands are used principally with the
pattern matching commands which are described in the next
section.
ATOM(exp) is TRUE if exp is atomic (i.e. a number or name) else
FALSE. Thus ATOM(5) is TRUE while ATOM(A[1]) and ATOM(SIN(X))
are FALSE. (Assuming A[1] and X are unbound.)
CONSTANT(exp) is TRUE if exp is a constant (i.e. composed of
numbers including %PI, %E, %I or any variables bound to
constant or made constant [see section 7.10]) else FALSE. Any
function whose arguments are constant is also considered to be
a constant.
INTEGER(exp) is TRUE if exp is an integer else FALSE.
FLOATNUM(exp) is true if exp is a floating point number else
FALSE.
NUMBER(exp) is TRUE if exp is an integer or a floating point
number else FALSE.
RATNUM(exp) is TRUE if exp is a rational number (includes
integers) else FALSE.
LISTP(exp) is TRUE if exp is a list else FALSE.
MATRIXP(exp) if TRUE is exp is a matrix else FALSE.
RATP(exp) is TRUE if exp is in CRE or extended CRE form else
FALSE.
The relationship among some of these commands is shown below.
Type Testing Commands page 7.7-2
CONSTANT?
no yes
ATOM? ATOM?
no yes no yes
X+1 X RATNUM? NUMBER?
no yes no yes
F(1) 1/2 %E X<>
%I
%PI
INTEGER?
no yes
1.2 -3
(FLOATNUM)
<> means that X has been made constant via MAKECONSTANT(X).
(see 7.10)
Pattern Matching Commands page 7.8-1
7.8 Pattern Matching and Related Commands
The pattern matching commands permit the user to test ex-
pressions for combinations of syntactic and semantic patterns
and to automatically have variables set to parts of expres-
sions which fit the patterns.
It is also possible to add simplification rules which
apply to user or system defined functions. Some examples are
given in this section but a more complete explanation with
further examples will be made available in a forthcoming
document.
FREEOF(x1,x2,...,expr) yields TRUE if the xi do not occur in expr
and FALSE otherwise. The xi are atoms or they may be
subscripted names, functions (e.g. SIN(X) ), or operators
enclosed in "s.
(C1) FREEOF(Y,SIN(X+2*Y));
(D1) FALSE
(C2) FREEOF(COS(Y),"*",SIN(Y)+COS(X));
(D2) TRUE
MATCHDECLARE(patternvar,predicate) associates a predicate with a
pattern variable so that the variable will only match expres-
sions for which the predicate is not FALSE. For example after
MATCHDECLARE(Q,FREEOF(X,%E)) is executed, Q will match any ex-
pression not containing X or %E. If the match succeeds then
the variable is set to the matched expression. The predicate
(in this case FREEOF) is written without the last argument
which should be the one against which the pattern variable is
to be tested.
The first argument may also be a list of pattern
variables all of which are to have the associated predicate.
For pattern matching, predicates refer to functions which
are either FALSE or not FALSE (any non FALSE value acts like
TRUE).
MATCHDECLARE(var,TRUE) will permit var to match any ex-
pression.
MATCHDECLARES is a list of the variables which have been
declared to have associated pattern matching predicates.
DEFMATCH(progname,pattern,patvar1,...,patvarn) creates a function
of n+1 arguments with the name progname which tests an expres-
sion to see if it can match a particular pattern. The pattern
is some expression containing pattern variables
patvar1,...,patvarn either explicitly, or implicitly in a
Pattern Matching Commands page 7.8-2
previous MATCHDECLARE command. The first argument to the
created function progname, is an expression to be matched
against the "pattern" and the other n arguments are the actual
variables occurring in the expression which are to take the
place of dummy variables occurring in the "pattern". Thus the
patvars in the DEFMATCH are like the dummy arguments to the
SUBROUTINE statement in FORTRAN. When the function is
"called" the actual arguments are substituted. For example:
(C1) NONZEROANDFREEOF(X,E):= IF E#0 AND FREEOF(X,E)
THEN TRUE ELSE FALSE$
(IS(E#0 AND FREEOF(X,E)) is an alternative but equivalent function
definition - see sect. 7.12 )
(C2) MATCHDECLARE(A,NONZEROANDFREEOF(X))$
(C3) MATCHDECLARE(B,FREEOF(X))$
(C4) DEFMATCH(LINEAR,A*X+B,X)$
This has caused the function LINEAR(exp,var1) to be
defined. It tests exp to see if it is of the form A*var1+B
where A and B do not contain var1 and A is not zero.
DEFMATCHed functions return (if the match is successful) a
list of equations whose left sides are the pattern variables
and whose right sides are the expressions which the pattern
variables matched. The pattern variables are also set to the
matched expressions. If the match fails, the function returns
FALSE. Thus LINEAR(3*Z+(Y+1)*Z+Y**2,Z) would return [B=Y**2 ,
A=Y+4 , X=Z]. Any variables not declared as pattern variables
in DECLARE or in DEFMATCH which occur in "pattern" will match
only themselves so that if the third argument to the DEFMATCH
in (C5) had been omitted, then LINEAR would only match expres-
sions linear in X, not in any other variable.
(C3) MATCHDECLARE([A,F],TRUE)$
(C4) CONSTINTERVAL(L,H):=IF CONSTANT(H-L) THEN TRUE
ELSE FALSE$
(C5) MATCHDECLARE(B,CONSTINTERVAL(A))$
(C6) MATCHDECLARE(X,ATOM)$
(C7) DEFMATCH(CHECKLIMITS,'INTEGRATE(F,X,A,B))$
(C8) 'INTEGRATE(SIN(T),T,X+%PI,X+2*%PI)$
(C9) CHECKLIMITS(%);
(D9) [B = X + 2 %PI, A = X + %PI, X = T,
F = SIN(T)]
Pattern Matching Commands page 7.8-3
(C10) 'INTEGRATE(SIN(T),T,0,X)$
(C11) CHECKLIMITS(%);
(D11) FALSE
DEFRULE(rulename,pattern,replacement) defines and names a
replacement rule for the given pattern. If the rule named
rulename is applied to an expression (by one of the APPLY com-
mands below), every subexpression matching the pattern will be
replaced by the replacement. All variables in the replacement
which have been assigned values by the pattern match are
assigned those values in the replacement which is then simpli-
fied. The rules themselves can be treated as functions which
will transform an expression by one operation of the pattern
match and replacement. If the pattern fails, the value of the
rule application is FALSE.
APPLY1(exp,rule1,...,rulen) applies the first rule to exp until it
fails, then recursively applies the same rule to the subex-
pressions of exp, left-to-right, until the first rule has
failed on all subexpressions. Then the second rule is applied
in the same fashion. When the final rule fails on the final
subexpression, the application is finished.
APPLY2(exp,rule1,...,rulen) differs from APPLY1 in that if the
first rule fails on a given subexpression, then the second is
applied, etc. Only if they all fail on a given subexpression
is the whole set of rules applied to the next subexpression.
If one of the rules succeeds, then the same subexpression is
reprocessed, starting with the first rule.
MAXAPPLYDEPTH [10000] is the maximum depth to which
APPLY1 and APPLY2 will delve.
TELLSIMPAFTER(pattern,replacement) defines a replacement for pat-
tern which the MACSYMA simplifier uses after it applies the
built-in simplification rules. The pattern may be anything
but a single variable or a number.
TELLSIMP(pattern,replacement) is similar to TELLSIMPAFTER but
places new information before old so that it is applied before
the built-in simplification rules. The pattern may not be a
sum, product, single variable, or number.
RULES is a list of names having simplification rules added
to them by DEFRULE, TELLSIMP, or TELLSIMPAFTER.
(C1) MATCHDECLARE(X,FREEOF(%I))$
(C2) TELLSIMP(SIN(%I*X),%I*SINH(X));
RULE PLACED ON SIN
Pattern Matching Commands page 7.8-4
[SINRULE1, SIMP-SIN]
(SINRULE1 is the name assigned to the TELLSIMP rule from (C2)
and SIMP-SIN is the internal name of the built-in simplifier
rule.)
(C3) TRIGEXPAND(SIN(X+%I*Y));
SIN(X) COS(%I Y) + %I COS(X) SINH(Y)
LETSIMP(expr) will continually apply the substitution rules
previously defined by the command LET (see below) until no
further change is made to expr.
LET(prod,repl,predname,arg1,arg2,...,argn) defines a substitution
rule for LETSIMP such that prod gets replaced by repl. prod
is a product of positive or negative powers of the following
types of terms:
(1) Atoms which LETSIMP will search for literally unless
previous to calling LETSIMP the MATCHDECLARE command is used
to associate a predicate with the atom. In this case LETSIMP
will match the atom to any term of a product satisfying the
predicate.
(2) Kernels of one argument such as SIN(X), N!, etc. As
with atoms above LETSIMP will look for a literal match unless
MATCHDECLARE is used to associate a predicate with the
argument of the kernel.
A term to a positive power will only match a term having
at least that power in the expression being LETSIMPed. A term
to a negative power on the other hand will only match a term
with a power at least as negative. In the case of negative
powers in "product" the switch LETRAT must be set to TRUE (see
below).
If a predicate is included in the LET command followed by
a list of arguments, a tentative match (i.e. one that would be
accepted if the predicate were omitted) will be accepted only
if predname(arg1',...,argn') evaluates to TRUE where argi' is
the value matched to argi. The argi may be the name of any
atom or the argument of any kernel appearing in prod. repl
may be any rational expression. If any of the atoms or
arguments from prod appear in repl the appropriate
substitutions will be made.
LETRAT [FALSE] when FALSE, LETSIMP will simplify the
numerator and denominator of expr independently and return the
result. Substitutions such as N!/N goes to (N-1)! will fail.
To handle such situations LETRAT should be set to TRUE, then
the numerator, denominator, and their quotient will be
simplified in that order.
Pattern Matching Commands page 7.8-5
REMLET(prod1,prod2,...) deletes substitution rules previously
defined by LET. The order of the terms in prodi are not
important.
REMLET() deletes all previously defined substitution rules.
If a substitution is to be changed using the same
product, REMLET need not be called, just redefine the
substitution using the same product (literally) with the LET
command and the new replacement and/or predicate name. Should
REMLET(product) now be called the original substitution rule
will be revived.
(C1) MATCHDECLARE([A1,A2],TRUE)$
(C2) ONELESS(X,Y):=IS(EQUAL(X,Y-1))$
(C3) LET(A1*A2!,A1!,ONELESS,A2,A1);
(D3) A1 A2! --> A1! WHERE ONELESS(A2, A1)
(C4) LETRAT:TRUE$
(C5) LET(A1!/A1,(A1-1)!);
A1!
(D5) --- --> (A1 - 1)!
A1
(C6) LETSIMP(N*M!*(N-1)!/M);
(D6) (M - 1)! N!
Graphing Commands page 7.9-1
7.9 Graphing
The commands described below produce point-plots of
functions given either explicity or as tabulated values.
Further detail is given in section 11.0.
PLOT(exp,var,low,high) produces an asterisk-plot of the expression
exp as var (the independent variable) ranges from low to high.
An optional fifth argument of INTEGER causes PLOT to choose
only integer values for var in the given domain.
GRAPH(xlist,ylist,xlabel,ylabel) graphs the two lists of data
points, and labels the axes as indicated or omits labels if
just the first two arguments are given. The variables
SCOPEHEIGHT and LINEL affect the height and width of the plot.
Utility, Input-Output, and Display Commands page 7.10-1
7.10 Utility, Input-Output, and Display
This section contains many commands which among other
actions (1) obtain or store information about the user's
functions and variables, (2) affect the display of expres-
sions, (3) store or retrieve expressions from disk, and (4)
freeup storage.
TRANSLATE(f1,f2,...) will translate the user defined functions
f1,f2,... from the MACSYMA language to LISP (i.e. it makes
them EXPR's). This results in a gain in speed when they are
called but prevents them from being displayed or edited in
MACSYMA. The functions must be in the form:
F(x1,x2,...):=BLOCK([v1,v2,...],
MODEDECLARE(y1,mode1,y2,mode2,...),...)
Where the x1,x2,... are the parameters to the function and the
v1,v2,... are the local variables. For more efficient code
resulting from translation, the function MODEDECLARE may be
used immediately following the list of local variables to
declare the mode of variables used in F. Its arguments are
pairs consisting of a variable yi (which is either an xi or
vi) and a mode which is one of INTEGER, FLOAT, POLY (for poly-
nomial), or CRE (for expression in CRE form).
It is also possible to declare the mode of arrays by
mentioning the array name as one argument and making the next
argument ARRAY(mode). yi may also be a list of variables all
of which are declared to have modei. Additionally one may
declare the mode of the result of a function by using
VALUE(name) as an argument where name is the name of the
function. For example the command
MODEDECLARE([VALUE(FUN1),X],POLY,Q,ARRAY(FLOAT)) declares that
X and the value returned by FUN1 are polynomials and that Q is
an array of floating point numbers.
One can translate functions stored in a file by giving
TRANSLATE an argument which is a file specification. This is
a list of the form [FN1,FN2,DVC,USER] where FN1 FN2 is the
name of the file of MACSYMA functions and DVC is the device
(usually DSK) where the file is kept and USER is the name of
the user's file directory.
The result returned by TRANSLATE is a list of the names
of the functions TRANSLATEd. In the case of a file transla-
tion the corresponding element of the list is a list of the
first and second new file names containing the LISP code
resulting from the translation. This will be FN1 LISP on
DVC:USER;. The file of LISP code may be read into MACSYMA by
using the LOADFILE command (see below).
Utility, Input-Output, and Display Commands page 7.10-2
COMPILE(f1,f2,...) will compile the user defined functions
f1,f2,... from MACSYMA to machine language (i.e. it makes them
SUBR's). This results in a further gain in speed over the
TRANSLATEd version. The functions are in the form described
under the TRANSLATE command.
DEFINE(f(x1,...),body) is equivalent to f(x1,...):''body but when
used inside functions it happens at execution time rather than
at the time of definition of the function which contains it.
(see sect. 4.0)
ERROR(arg1,arg2,...) will evaluate and print its arguments and
will then return to top level MACSYMA. This is useful for
breaking out of nested functions if an error condition is
detected, especially in BATCH files where one can't type
control-↑.
NOUN(name1,..) makes the named functions NOUNs. (see sect. 4.0)
MAKECONSTANT(name1,name2,...) will make the named atomic variables
constant causing them to be displayed as constants i.e.,
before variables. In addition if B is madeconstant then
A.(B*C) will become B*(A.C).
%TH(i) is the ith previous computation. That is, if the next ex-
pression to be computed is D(j) this is D(j-i). This is
useful for BATCH files or for refering to a group of D
expressions. For example, if SUM is initialized to 0 then
FOR I:1 THRU 10 DO SUM:SUM+%TH(I) will set SUM to the sum of
the last 10 D expressions.
DISPFUN(f) displays the definition of the user defined function f.
The command STRING (see below) may then be used in order to
edit the function.
DISPRULE(rulename) will display a rule with the name rulename as
was given by DEFRULE, TELLSIMP, or TELLSIMPAFTER or a pattern
defined by DEFMATCH. For example, the first rule modifying
SIN will be called SINRULE1. (see sect 7.8)
REMFUNCTION(f1,f2,...) removes the user defined functions
f1,f2,... from MACSYMA. If there is only one argument of ALL
then ALL functions are removed.
REMVALUE(name1,name2,...) removes user variables (including single
array elements) and matrices from the system. If name is ALL
then all values and matrices are removed. Values are those
items given names by the user as opposed to those which are
automatically labeled by MACSYMA as Ci, Di, or Ei.
Utility, Input-Output, and Display Commands page 7.10-3
REMARRAY(name1,name2,...) removes arrays and frees the storage
occupied. If name is ALL then all arrays are removed. It
may be necessary to use this command if it is desired to
redefine the values in a hashed array.
REMOVERULE(function,rulename) will remove a rule with the name
rulename from the function which was placed there by DEFRULE,
TELLSIMP, or TELLSIMPAFTER. If rulename is ALL, then all
TELLSIMP and TELLSIMPAFTER rules will be removed
REMOVE(arg1,prop1,arg2,prop2,...) argi is either a single name or
a list of names from which the property propi is to be
removed. Propi may be ARRAY, FUNCTION, VALUE, DEPENDS, ALIAS,
BINDTEST, or RULE.
KILL(arg1,arg2,...) eliminates its arguments from the MACSYMA
system. If argi is a variable (including a single array ele-
ment), function, or array, the designated item with all of its
properties is removed from core and the storage it occupies is
reclaimed. If argi=LABELS then all input, intermediate, and
output lines to date (but not other named items) are elimina-
ted. If argi is the name of any of the other information
structures (see the end of this section) every item in that
class (and its properties) is KILL'ed and if argi=ALL then
every item on every information structure list previously
defined as well as LABELS is KILL'ed. If argi=a number (say
n), then the last n lines (i.e. the lines with the last n line
numbers) are deleted. If argi is of the form [m,n] then all
lines with numbers between m and n inclusive are killed.
KILL removes all properties from the given argument thus
KILL(VALUES) will kill all properties associated with every
item on the VALUES list whereas the REMOVE set of functions
remove a specific property. Also the latter print out a list
of names or FALSE if the specific argument doesn't exist
whereas KILL always prints out "DONE" even if the named item
doesn't exist.
ALIAS(newname1,oldname1,...) provides an alternate name for a
function (user or system), variable, array, etc. Any even
number of arguments may be used.
REMALIAS(name1,...) removes alternate names created by ALIAS.
SAVE(args) saves quantities described by its arguments on disk and
keeps them in core also. (see section 10.3).
STORE(args) same as SAVE but doesn't retain quantities in core.
(see section 10.3).
Utility, Input-Output, and Display Commands page 7.10-4
DSKGC(TRUE) will cause user defined values, functions, arrays, and
line labelled expressions to be automatically stored on disk
whenever the system determines that the available in-core
space is getting low. DSKGC(FALSE) will turn off the
automatic storing mechanism activated by DSKGC(TRUE). (see
also sect. 10.2).
UNSTORE(name1,...) brings the named expressions into core that
were stored away by use of the STORE command in the current
MACSYMA. (see section 10.3).
RESTORE(file-specification) reinitializes all quantities filed
away by a use of the SAVE or STORE commands, in a prior
MACSYMA session, from the file give by file-specification
without bringing them into core. (see section 10.4).
LOADFILE(fn1,fn2,device,username) loads a file as designated by
its arguments. This command may be used to bring back into
core quantities that were stored from a prior MACSYMA session
by use of the SAVE or STORE commands. If device and username
are omitted then the last device and username seen (initially
DSK and user's system name) will be used. fn1 fn2 must be a
file of LISP functions and expressions, not of MACSYMA
commands, in which case BATCH or DEMO is to be used. (see
10.4)
REMFILE() removes files created by the secondary storage scheme in
the MACSYMA under use (see section 10.3). REMFILE(TRUE) does
what REMFILE() does and in addition deletes any files which
have been created by the SAVE or STORE commands but which have
not been assigned names by the user.
TIME(Di1,Di2,...) gives a list of the time in milliseconds taken
to compute the Di.
LOGOUT() causes the user to be logged out and all jobs deleted.
This is useful when it is desired to BATCH in a file and have
the terminal logged out automatically when the computations
are finished. (Equivalent to ↑|Z and :LOGOUT)
QUIT() kills the current MACSYMA but doesn't affect the user's
other jobs. (Equivalent to ↑|Z and :KILL).
BATCH(file-specification) reads in and evaluates MACSYMA commands
from a file. (see section 9.0).
DEMO(file-specification) same as BATCH but pauses after each com-
mand and continues when a space is typed. (see section 9.0).
Utility, Input-Output, and Display Commands page 7.10-5
BATCON(argument) continues BATCHing in a file which was
interrupted. (see section 9.0).
PLAYBACK(arg) "plays back" input and output lines. If arg=n (a
number) the last n expressions (Ci, Di, and Ei count as 1
each) are "played-back", while if arg is omitted, all lines
are. arg=SLOW places PLAYBACK in a slow-mode similar to
DEMO's (as opposed to the "fast" BATCH). This is useful in
conjunction with SAVE or STRINGOUT (see below) when creating a
secondary-storage file in order to pick out useful expres-
sions. If arg=TIME then the computation times are displayed
as well as the expressions. arg=STRING strings-out (see
STRING command below), all input lines when playing back
rather than displaying them. One may include more than one
option at a time as long as a number (if given) is given first
e.g., PLAYBACK(10,SLOW).
WRITEFILE(device,username) opens up a file for writing. Usually
device is DSK.
CLOSEFILE(filename1,filename2) closes a file opened by WRITEFILE
and gives it the name filename1 filename2. Thus to save a
file consisting of the display of all input and output during
some part of a session with MACSYMA the user issues a
WRITEFILE, transacts with MACSYMA, then issues a CLOSEFILE.
The user can also issue the PLAYBACK command after a
WRITEFILE to save the display of previous transactions. (Note
that what is saved this way is a copy of the display of ex-
pressions not the expressions themselves). To save the actual
expression in internal form the SAVE command may be used. The
expression can then be brought back into MACSYMA via the
RESTORE command. To save the expression in a linear form
which may then be BATCHed in later the STRINGOUT command is
used. (see below)
STRING(expr) converts expr to MACSYMA's linear notation (similar
to FORTRAN's) just as if it had been typed in and puts expr
into the buffer for possible editing (in which case expr is
usually Ci) (see section 8.1). The STRING'ed expression
should not be used as if it were a two-dimensional expression.
STRINGOUT(file-description,A1,A2,..) outputs to a file given by
file-description ([filename1,filename2,device,username]) the
values given by A1,A2,.. in a MACSYMA readable format. The
file-description may be omitted, in which case the default
values will be used. (see sect. 10.2 - C) The Ai are usually
C expressions or may be ALL meaning all C expressions. This
command may be used to create a file of FORTRAN statements by
doing some simple editing on the strungout expressions.
Utility, Input-Output, and Display Commands page 7.10-6
READ(string1,...) prints its arguments literally then reads in and
evaluates one expression. For example, A:READ("ENTER THE
NUMBER OF VALUES").
PRINT(exp1,exp2,...) evaluates and displays its arguments one
after the other "on a line" starting at the leftmost position.
If expi is unbound or is preceded by a single quote or is
enclosed in "s then it is printed literally. For example,
PRINT("THE VALUE OF X IS ",X). The value returned by PRINT is
the value of its last argument. No E lines are generated.
PRINDISPLAY(expr1,expr2,..) displays the expri centered one per
"line". This is like the DISP command below but doesn't
generate intermediate E labels.
DISPLAY(expr1,expr2,...) displays equations whose left side is
expri, and whose right side is the value of the expression
centered on the line. This command is useful in blocks and
FOR statements in order to have intermediate results
displayed. The arguments to DISPLAY are usually atoms,
subscripted variables, or function calls. (however see the
DISP command below.)
(C1) DISPLAY(B[1,2]);
2
(E1) B = X - X
1, 2
(D1) [E1]
DISP(expr1,...) is like DISPLAY but only the value of the
arguments are displayed rather than equations. This is useful
for complicated arguments which don't have names where only
the value of the argument is of interest and not the name.
DISPTERMS(expr) displays its argument in parts one below the
other. That is, each term in a sum or factor in a product is
displayed separately. This is useful if expr is too large to
be displayed. For example if P1, P2, ... are very large
expressions then the display program may run out of storage
space in trying to display P1+P2+... all at once however
DISPTERMS(P1+P2+...) will display P1, then below it P2, etc.
If an exponential expression is too large to be
displayed as A**B it will appear as EXPT[A,B].
PAGEPAUSE(TRUE) will cause CRT consoles to pause when the end of
the screen is reached and wait for a control-U to be typed in
order to continue displaying. PAGEPAUSE(FALSE) will terminate
this mode.
Utility, Input-Output, and Display Commands page 7.10-7
BOTHCASES(TRUE) will cause MACSYMA to retain lower case text as
well as upper case. Note however that the names of any
MACSYMA special variables or functions must be typed in upper
case. BOTHCASES(FALSE) caues MACSYMA to revert to the normal
mode of lower to upper case conversion.
MACSYMA Special Variables for I/O, Status, and Display
Some MACSYMA commands (e.g. MATCHDECLARE, TELLSIMP, etc.)
are used for their effect on the system and on other commands
rather than for any value which they return. Certain
variables henceforth referred to as "information structures"
contain values which reflect the use of these commands or
which reflect the status of some aspect of the MACSYMA system.
These are as follows.
VALUES - a list of user variables which have values.
FUNCTIONS - a list of user functions defined so far.
ARRAYS - a list of user arrays (declared or hashed)
defined thus far.
LABELS - a list of C, D, and E lines which have values.
MATCHDECLARES - a list of the variables which have
associated pattern matching predicates MATCHDECLAREd for
them.
RULES - a list of rules defined using DEFMATCH, DEFRULE,
TELLSIMP, or TELLSIMPAFTER.
ALIASES - a list of the user created aliases. (via the
ALIAS command)
DEPENDENCIES - a list of user declared functional
dependency relations just as they were given to the
DEPENDENCIES command.
GRADEFS - a list of functions which have user declared
gradient properties from the GRADEF command.
TIME [FALSE] - if TRUE causes MACSYMA to print the time taken
by each computation. (This figure does not include I/O time).
LASTTIME - the time to compute the last expression in
milliseconds.
Utility, Input-Output, and Display Commands page 7.10-8
LINENUM - the line number of the last expression.
NOLABELS [FALSE] - if TRUE then no labels will be bound except
for E lines generated by the SOLVE command (sect. 7.3). This
is most useful in the "BATCH" mode where it eliminates the
need to do KILL(LABELS) in order to free up storage.
EXPTDISPFLAG [TRUE] - if TRUE MACSYMA displays expressions
with negative integer exponents using quotients e.g., X**(-1)
as 1/X.
PFEFORMAT [FALSE] if TRUE will cause rational numbers to
display in a linear form and denominators which are integers
to display as rational number multipliers.
NOSTAR [TRUE] - if FALSE causes multiplication to be displayed
explicitly with an * between operands.
DISPFLAG [TRUE] - if set to TRUE within a BLOCK (see sect.
3.11) will permit the display of output generated by functions
called from within the BLOCK. Display from within a block
normally does not occur unless there is an explicit call to
functions which print such as DISPLAY, PRINT, etc. (Currently
this applies only to the SOLVE commands which generates
several lines of output).
NOUNDISP [FALSE] - if TRUE will cause NOUNs to display with a
single quote. This switch is always TRUE when displaying
function definitions.
POWERDISP [FALSE] - if TRUE will cause polynomials to display
as truncated power-series, i.e., with the lowest power first.
INCHAR [C] - the alphabetic prefix of the names of expressions
typed by the user.
LINECHAR [E] - the alphabetic prefix of the names of
intermediate displayed expressions.
OUTCHAR [D] - the alphabetic prefix of the names of outputted
expressions.
CURSOR [] is the prompt symbol of the MACSYMA editor and
(MACSYMA-BREAK). (see sections 8 and 12).
GENINDEX [I] -the alphabetic prefix of the index of summation
for generated sums. (The values of above four variables may
be any number of characters though the default is a single
character.)
Utility, Input-Output, and Display Commands page 7.10-9
IBASE [10] - the base for inputting numbers.
BASE [10] - the base for display of numbers.
LINEL - the length of the printed line on the terminal. Also
used for plotting (see section 11.0).
SCOPEHEIGHT - the height of the area used for plotting. (see
section 11.0).
List Handling Commands page 7.11-1
7.11 List Handling and LISP-like functions
APPEND(list-1,list-2,...) returns a single list of the elements of
list-1 followed by the elements of list-2,...
Thus APPEND([Y+X,0,-3.2],[2.5E20,X]) is
[Y+X,0,-3.2,2.5E20,X].
CONS(exp,list) returns a new list constructed of the element exp
as its first element, followed by the elements of list.
ENDCONS(exp,list) returns a new list consisting of the elements of
list followed by exp.
MEMBER(exp,list) returns TRUE if exp occurs as a member of list
(not within a member). Otherwise FALSE is returned.
REVERSE(list) reverses the order of the members of list (not the
members themselves).
NULL(list) returns TRUE if list is empty else FALSE.
APPLY(function,list) gives the result of applying the function to
the list of its arguments. This is useful when it is desired
to compute the arguments to a function before applying that
function. For example, if L is the list [1,5,-10.2,4,3], then
APPLY(MIN,L) gives -10.2. APPLY is also useful when calling
functions which do not evaluate their arguments if it is
desired to cause evaluation of them. For example, if FILESPEC
is a variable bound to the list [TEST, CASE] then
APPLY(CLOSEFILE,FILESPEC) is equivalent to
CLOSEFILE(TEST,CASE).
MAP(fn,list) yields a list each member of which is the result of
applying the function fn to the corresponding member of list.
fn is the name of a function of one argument or for functions
of more than one argument is of the form LAMBDA([X],defn)
where [X] is the dummy variable to be used in the function
defn and which will take on the value of successive elements
of list. For example MAP(LAMBDA([Y],Y+1),[2,10,1]) yields
[3,11,2].
MAP(fn,exp) is also acceptable. In this case fn is applied to
each part of exp (term of a sum, row of a matrix, etc.) For
example, MAP(RATSIMP,(X**2+2*X+1)/(X+1)+(X-1)/(X**2-1)) yields
1/(X+1)+X+1.
One of the uses of this command is to MAP a function
(e.g. PARTFRAC) onto each term of a very large expression
where it ordinarily wouldn't be possible to use the function
on the entire expression due to an exhaustion of list storage
space in the course of the computation.
List Handling Commands page 7.11-2
MAPLIST(fn,exp) yields a list of the applications of fn to the
parts of exp. This differs from MAP(fn,exp) which returns an
expression with the same main operator (except for
simplifications) as exp has. fn is of the same form as in
MAP.
Examples
(C1) UNION(X,Y):=IF NULL(X) THEN Y ELSE
IF MEMBER(T:FIRST(X),Y) THEN UNION(REST(X),Y)
ELSE CONS(T,UNION(REST(X),Y)$
(C2) UNION([A,B,1,1/2,X**2],[-X**2,A,Y,1/2]);
2 2 1
(D2) [X , 1, B, - X , A, Y, -]
2
In this example T is assigned the value of FIRST(X) in the
call to MEMBER and is referenced later in CONS(T,Y).
(C3) BERNPOLY(X,5);
4 3
5 5 X 5 X X
(D3) X - ---- + ---- - -
2 3 6
(C4) MAPLIST(NUMFACTOR,%);
5 5 1
(D4) [1, - -, -, - -]
2 3 6
(C5) APPLY(MIN,%);
5
(D5) - -
2
The following four functions permit the manipulation of
"property lists." These are objects attached to variables in
MACSYMA which associate information with the variables.
PUT(var,value,indicator) associates with the variable var an
indicator with the given value. (like PUTPROP in LISP).
QPUT(var,value,indicator) is similar to PUT but it doesn't
evaluate its arguments. (like DEFPROP in LISP).
List Handling Commands page 7.11-3
GET(var,indicator) retrieves the value of the indicator associated
with the given variable. (like GET in LISP).
REM(var,indicator) removes the indicator and its value from the
given variable. (like REMPROP in LISP).
List Handling Commands page 7.11-1
7.12 The Comparison Commands
IS(expr) tries to determine if expr (which must evaluate to a
predicate) is TRUE or FALSE. If it can't then a simplified
but equivalent form of expr is returned. TRUE (or FALSE) is
returned only if the relation expr (which is composed of
variables, comparison operators, and predicate functions) is
TRUE (or FALSE) for all possible values of its variables. The
operator = compares two expressions to determine if they are
identical after all evaluations have been done. Thus
IS(X+1=2) returns TRUE if and only if X has the value 1.
EQUAL(expr1,expr2) on the other hand returns TRUE (or FALSE)
if and only if expr1 and expr2 are equal (or not equal) for
all possible values of their variables (as determined by
RATSIMP). Thus IS(EQUAL((X+1)**2,X**2+2*X+1)) returns TRUE
whereas if X is unbound IS((X+1)**2=X**2+2*X+1) returns FALSE.
If a determination can't be made with EQUAL then a simplified
but equivalent form is returned whereas = always causes either
TRUE or FALSE to be returned. All variables occurring in expr
are presumed to be real valued. The IS command is equivalent
to EV(expr,PRED).
(C1) IS(X**2 >= 2*X-1);
(D1) TRUE
(C2) IS(EQUAL(Y**3,1) OR LOG(X) > 0);
(D2) EQUAL(Y,1) OR X-1>0
ASSUME(pred1,pred2,...) stores information in MACSYMA about the
relation among various variables and their relation to zero
(>, =, etc.) on the basis of the given predicates. This
information can be utilized later in conditional statements
such as IF or in the commands IS, SIGN or INTEGRATE (certain
cases of integration requiring sign information).
The information is added to the data base and is tested
for consistency against previously given relations. The form
ASSUME(list) where list is a list of predicates may also be
used.
(C1) ASSUME(Z>0)$
(C2) IS(LOG(1-Z) > LOG(1+Z));
(D2) FALSE
FORGET(pred1,pred2,...) removes relations established by ASSUME.
The predicates may be any expressions equivalent to (but not
necessarily identical to) those previously ASSUMED.
FORGET(list) is also a legal form.
SIGN(expr) uses ASSUMEd information (if any) or asks the user in
determining the sign (POS, NEG, or ZERO) of expr.
Debugging Commands page 7.13-1
7.13 Debugging Commands (see also section 12.0)
TRACE(name1,name2,...) gives a trace printout whenever the
functions mentioned are referenced. TRACE() prints a list of
the functions currently under TRACE.
UNTRACE(name1,...) removes tracing incurred by the TRACE command.
UNTRACE() removes tracing from all functions.
REMTRACE() removes the tracing facilities from MACSYMA thus
freeing up some storage. They will be reloaded when TRACE is
used again.
BINDTEST(var1,var2,...) causes MACSYMA to give an error message
whenever any of the vari occur unbound in a computation.
DEBUGMODE(switch) causes MACSYMA to enter a special debugging mode
if switch is TRUE and to terminate that mode if switch is
FALSE.
TOPLEVEL recursively returns control to top level MACSYMA from a
(MACSYMA-BREAK) pushing the current computation if one was
broken.
TOBREAK() returns to a (MACSYMA-BREAK) which was left by typing
TOPLEVEL.
EXIT resumes a computation interrupted by control-A or by an error
break caused by an error when DEBUGMODE(TRUE) has been
executed.
Special Variables
BACKTRACE has as value a list of all functions currently
entered.
%% the value of the last computation performed while in a
(MACSYMA-BREAK).
DEBUG [FALSE] if TRUE causes a message to be printed each time
a bound variable is used for the first time in a computation.
PREDERROR [FALSE] - if TRUE causes a message to be printed
whenever the predicate of an IF statement or an IS command
fails to evaluate to either TRUE or FALSE.
The MACSYMA Editor page 8-1
8.0 The MACSYMA Editor
8.1 Introduction
The major features of the editor are single (alphabetic)
character commands, a varied assortment of commands (14 of them),
concatenation of commands as in TECO (the PDP-10 file editor),
mnemonics for command names (once you know them, as R means "move
in the Reverse direction" and not "move Right"; B means "move to
the Bottom" and not "move Backwards"), and compatibility with TECO
as to command names (in the case of C, D, G, I, J, K, L, R, and
S).
8.2 Entering the Editor
At any time while the user is inputting a command to MACSYMA,
he may enter the input-stream editor by typing "altmode" or
"escape" henceforth denoted by <$>. The editor is given the
string of characters typed so far in the current input command.
In the case of a detected syntax error, upon typing <$> the entire
previous command string will be given to the editor. Before
typing in the next command string, one may always elect instead to
edit the previous command string in this manner. This is useful
in saving one from having to retype a command similar to the
previous one when that command didn't have the desired effect.
Note however, that <$> must be the first character typed on the
next command line. Any other character causes the edit buffer to
be flushed.
One may also request the editor to edit or modify a
previously accepted input command by using the STRING command in
MACSYMA. Typing STRING(Ci) will restore the expression labeled as
Ci as the current input string. This enables the user to modify
it by then immediately typing <$>.
All the commands to the editor reference a cursor (displayed
as an underscore or back-arrow, depending on the console) which is
displayed within or at either end of the string of characters
currently under edit (called the "input string" from now on). The
value of the variable CURSOR determines what character is used
(see 7.10).
The editor accepts a command string which must be terminated
by <$><$>. A command string is any concatenation of one or more
legal commands which will be processed in left-to-right order.
Display of the input string occurs at the end of the processing of
each command string. <$> is used to enter the editor, to exit
from the editor (as <$><$>), and to terminate insert or search
substrings. Otherwise, spurious <$>'s are ignored. Rubouts (the
rubout or delete key on the console) may be used at any point
prior to command termination to delete the last character typed in
(which is echoed at the console.) ?? deletes the entire command.
The MACSYMA Editor page 8-2
At any point prior to command termination, the user may type a
<control>K, and the editor will reprint the characters of the com-
mand typed so far. This is useful in case excessive rubouts have
obscured the sequence of characters in the command string.
Occasionally, one gets a syntax error because of omitting
characters from the end of a command (especially right
parentheses). By typing <$><$><$> immediately, as the first 3
characters of the next input line, the last command will be
automatically reproduced on the current input line at which point
one can supply the missing characters or rubout erroneous
characters. For example:
(C1) (((X+1)*X+2)*X+3$
( ( ( X + 1 ) * X + 2 ) * X + 3 ***$***
SYNTAX ERROR
PLEASE REPHRASE OR EDIT
(C1) <$>
(((X+1)*X+2)*X+3
<$><$>
(C1) (((X+1)*X+2)*X+3 )*X+4$
(In the above line the user's typing is underlined)
8.3 A Description of the Commands
Some commands may be prefixed by an integer (represented
below by "n") which usually may be positive or negative; although
it may be zero as well in the case of K, L, and W; and it must be
non-negative in case of W. The default value of n is +1. Except
in the case of R, if n is positive the commands operate toward the
right of the cursor, if n is negative they operate toward the
left. Only I and S may be suffixed. An error message will be
printed if an illegal command substring is encountered or if any
command substring fails. In case of such error, the processing of
the current command string will be terminated at that point, with
the offending command substring indicated.
Command Mnemonic Action
(Commands which move the cursor)
nC Character moves the cursor n characters.
nR Reverse moves the cursor n characters in the reverse
direction (nR = -nC).
J or Jump to top
T Top moves the cursor to the head of the input
The MACSYMA Editor page 8-3
string.
B Bottom moves the cursor to the end of the input
string.
nL Line moves the cursor to the right of the nth
carriage return (0L moves left); e.g., L
moves to the next line.
nSstring<$> Search moves the cursor to the right (left if n
is negative) of the nth occurrence of
"string" in the input string.
(Commands which delete characters)
nD Delete deletes n characters, and saves them in the
"save-register" (see the G command below).
nK Kill deletes all the characters through the nth
carriage return (0K kills left), and saves
them in the "save-register"; e.g., K deletes
the remainder of this line.
(Commands which insert characters)
Istring<$> Insert inserts the characters "string" at the
current cursor position. The cursor is
positioned at the right of the inserted
text.
G Get inserts at the current cursor position the
characters deleted by the last use of D or
K. Thus G may be used in combination with D
or K to move characters from one place to
another in the input string; or to recover
from an accidental use of D or K. There is
only one "save-register".
(Commands which control display of results)
P Print simply reprints the input string. This is
useful in case of console problems.
nW Window controls the window size of the display,
which is the maximum number of characters
displayed on each side of the cursor. This
is useful in case of slow consoles and large
input strings. 0W will cause only the
cursor to be displayed.
The MACSYMA Editor page 8-4
V View restores the display to full view, which is
the normal mode (affected only by W).
<$><$> will exit from the editor and is also the command
string terminator. Two examples of legal command strings are
4C3DIFOO<$><$> and -2SBAR<$>3R<$><$>. The first moves right over
four characters, deletes the next three characters, and inserts
FOO. The second searches from the current pointer position to the
beginning of the text for the second occurrence of BAR then moves
left over three characters.
Example
(C1) FOR I:1 STEP 5 THRU 50 DO
SUM:SUM+I$
FOR I : 1 STEP 5 THRU 50 DOSUM ***$*** : SUM + I
SYNTAX ERROR
PLEASE REPHRASE OR EDIT
(C1) <$>
FOR I:1 STEP 5 THRU 50 DO
SUM:SUM+I
LI <$><$>
FOR I:1 STEP 5 THRU 50 DO
SUM:SUM+I
<$><$>
(C1) FOR I:1 STEP 5 THRU 50 DO
SUM:SUM+I $
(D1)
The Batch Commands page 9-1
9.0 Batch Commands
9.1 Introduction
The Batch set of commands in MACSYMA, namely BATCH, DEMO, and
BATCON (mnemonic for BATch CONtinue), provide a facility for
executing commands stored on a disk file rather than in the usual
on-line mode. This facility has several uses, namely to provide a
reservoir for working commands, for giving error-free
demonstrations, or to help in organizing one's thinking in complex
problem-solving situations where modifications may be done via the
PDP-10 TECO file editor.
A batch file consists of a set of MACSYMA commands, each with
its terminating ; or $, which may be further separated by spaces,
carriage-returns, form-feeds, and the like. The BATCH and DEMO
commands have both a simple and more complicated format, which are
described below.
9.2 The Simple Format
BATCH(filename1, filename2, device, username)
(The same command format holds for DEMO as well.)
The arguments to BATCH (or DEMO) in this format specify the file
which is to be batched, in standard ITS format [8]. Here, each
file is specified by two filenames of at most six characters each,
the device the file is on, usually DSK, and the user file
directory. E.g. DEMO(FOO,BAR,DSK,BARF) calls for "demonstrating"
(see below) the file FOO BAR on the BARF disk directory. Latter
arguments to the BATCH or DEMO commands may always be omitted if
they are known from previous file-manipulating commands.
The BATCH command calls for reading in the commands from the
file one at a time, echoing them on the user console, and execu-
ting them in turn. Control is returned to the user console only
when serious errors occur or when the end of the file is met. Of
course, the user may quit out of the file-processing by typing
<control>G or <control>↑ at any point. (see sect 5.0) DEMO
differs from BATCH only in that it pauses after the execution of
each command, waiting for the user to type a space which tells it
to go on. If the user types any other character, file-processing
will then terminate, giving control over to the user console.
(The user may actually continue processing from the file at any
time - see the BATCON command below.)
9.3 The More Complicated Format
BATCH([fn1, fn2, dev, uname], delay-switch,
index-specification)
The Batch Commands page 9-2
The arguments to BATCH or DEMO in this mode are as follows:
The first argument is the file specification (as above),
enclosed in brackets.
The second argument, the delay-switch, may be answered by ON
or OFF (the default). This switch has to do with the temporary
inability of LISP, the system underlying MACSYMA, to have more
than one input file open at a time. If in the course of batching
in a file of commands, execution of a command forces a second file
to be input, this would ordinarily cause an error. However,
setting the delay-switch to ON causes the entire batch file to be
read in before execution of it begins, thus preventing the error.
The default for the delay-switch is OFF, as the circumstance
described above is not frequent, it takes some time to read in a
batch file, and one may always continue batching via the BATCON
command. As soon as the inability of LISP is removed, this switch
will no longer be needed.
The index-specification is given by one or two arguments, the
possibilities being: (In the following, m and n are positive
integers.)
(i) m. This indicates that processing is to begin with the mth
command in the file. Thus, the default for the
index-specification is 1.
(ii) m, n. This indicates that only the mth command through
the nth command are to be processed.
(iii) a variable (say FOO). FOO must be non-numeric and
neither TRUE nor FALSE. This causes file-processing to begin at
FOO (see sect 9.5) and continue until the end of the file. This
makes it unnecessary to count commands as required by (i) above.
(iv) variable (say FOO), continue-flag. The continue-flag is
either ON (the default, and unnecessary) or OFF. If OFF, this
enables one to separate a batch file into subfiles by prefixing a
command in the file with FOO. By using FOO as the
index-specification, one may execute only that subfile which
begins with FOO and ends with some other variable , or the end of
file. If the continue-flag is ON, this causes mode (iv) to
operate as (iii) above.
One can see that BATCH(FOO, BAR, DSK, BARF) and BATCH([FOO,
BAR, DSK, BARF], OFF, 1) are equivalent.
9.4 The BATCON command
The BATCON command is used to continue or change the last
BATCH or DEMO command, without it being necessary to mention again
BATCH or DEMO, the file specification, or the setting of the
delay-switch. Of course, if one wishes to change any of these, a
new call to BATCH or DEMO is required.
The possible argument(s) to BATCON is (are) as follows:
(i) a number
The Batch Commands page 9-3
(ii) number1, number2
(iii) a variable
(iv) variable, continue-flag
are all as above. The numeric arguments may involve the variable
BATCOUNT which is set to the number of the last expression
BATCH'ed in from the file. Thus BATCON(BATCOUNT-1) will resume
BATCH'ing from the expression before the last BATCH'ed in from
before. One other mode is possible:
(v) skip-flag. The skip-flag is useful if an error has
occurred while batching, or if the user wishes to interject com-
mands from the console while in DEMO-mode and then to continue
processing from the file. The skip-flag may be either TRUE or
FALSE. If FALSE, this indicates that processing is to continue
with the last command attempted (supposedly editted, in case of
error); if TRUE, this indicates that processing is to continue
with the next (untried) command in the file.
9.5 Miscellany
(1) Comments may be added to batch files at any point, and
will, of course, be treated as such when batching in the file. A
comment is any string beginning with /* and ending with */ as in
PL/I.
(2) Any command in a batch file may begin with variable.
This labels that command so that the file can be partitioned into
subfiles. If not in a subfile mode, this prefix will be treated
as a comment.
(3) When using the batch commands, it is inconvenient to keep
track of which Di label MACSYMA will assign to a computation; yet
later commands often need to refer to an earlier computation. One
way to get around this, of course, is for the user to explicitly
label some of his commands. A function %TH is also provided, such
that %TH(i), where i is positive, refers to the result of the ith
previous command. E.g., %TH(1) and the variable % both refer to
the same computation.
(4) When BATCHing in several files it is possible for one
file to unintentionally cause an error to occur in a subsequent
one by duplication of names. If the variable BATCHKILL is TRUE
however, then the effect of all previous BATCH files is nullified
(except for the setting of MACSYMA special variables) when the
next one is read in. (The default value of BATCHKILL is FALSE.)
Secondary Storage Commands page 10-1
10.0 Secondary Storage Commands
10.1 Introduction
There are two different reasons for wanting to use
secondary storage while running a MACSYMA. Sometimes the user's
intermediate expressions take up a lot of core, and it is impos-
sible to complete the job if all the intermediate expressions are
kept in core. In this case the user would like to have his
intermediate expressions written automatically to disk, in order
to free up core storage. On the other hand, some users would like
to save some expressions on disk so that they can be read back
into a future MACSYMA at a later time. In this case the user
would like to specify certain expressions to be stored away and to
name the disk file where they are to be stored. MACSYMA now
offers the user two secondary storage schemes. The user may ask
to have his expressions automatically filed away on disk. Or he
may, by means of the SAVE and STORE commands, exercise explicit
control over the storage of expressions. These latter commands
give the user more power and flexibility at the expense of a
greater effort. It is expected that the user whose only concern
is to run a big job which would not run without using secondary
storage will use the automatic storage scheme, while the user who
wishes to save expressions for use in later MACSYMAs will use the
SAVE and STORE commands.
10.2 Automatic Storage of Expressions
A- How to use it
To activate the automatic storage scheme the user merely
sets the MACSYMA variable DSKUSE [default value FALSE] to TRUE.
From this point on labelled expressions will be written out
periodically on disk. (A labelled expression is one which is
referred to by a linelabel, e.g. D4, C7, E12.) Once an expression
is written on disk it will no longer reside in core and most of
the core storage taken up by it will be released. When the user
attempts to reference an expression which has been stored on disk,
MACSYMA will retrieve the correct value from the disk file. In
this scheme expressions are written periodically to disk whenever
there are enough to write and enough to retain in core. (see
FILESIZE and RETAINNUM variables below). An alternative heuristic
to use in order to freeup some storage is to write out all line
labelled expressions, values, functions, and arrays not
periodically but when the garbage collector finds that space is
getting low. This is the purpose of the DSKGC function (see sect.
7.10).
If the user is dealing with large expressions then his
storage limit may be exceeded before FILESIZE+RETAINNUM
Secondary Storage Commands page 10-2
expressions have been generated. In this case the DSKGC method
should be used. If this situation does not occur and if the user
prefers to have some control over how many expressions are saved
in each file then the other scheme scheme should be used.
B- Cleaning up the disk
The automatic storage scheme will in general cause several
disk files to be created, which are of no further use after the
user has finished running his current MACSYMA. There is a
function of no arguments, REMFILE, which will delete all the files
created by the automatic storage scheme. Thus if the user does
not want these files to stay around, he should execute REMFILE()
before leaving MACSYMA. REMFILE will only delete files created in
the same MACSYMA to which the REMFILE command is given. In order
to delete files created in previous uses of MACSYMA it is
necessary to use the ED command in TECO (the system text editor),
or to use the DDT command :DELETE {device:username;} filename1
filename2.
C- Options
The user may specify how often files are written, how
large they are, what they will be named, and what gets stored in
them. Or he may accept the default values for all these. The
following MACSYMA variables are relevant.
FILENAME: The value of this variable is the first name
of the files which are generated by the
automatic disk storage scheme. The default
value is the first three characters of the
user's login name concatenated with a
three-digit random number (e.g. ECR684)
FILENUM: The value of this variable, a number, is the
second name of the last file written. Each
time a file is written, this value is first
increased by 1, so it must always be numeric.
It is initially set to 0.
FILESIZE: The value of this variable is the number of
expressions written into each file. The
default value is 10.
RETAINNUM: When the number of expressions in core reaches
FILESIZE+RETAINNUM a file is written. The
default value is 8.
DEV: The value of this variable is the default
device. It is initialized to DSK.
Secondary Storage Commands page 10-3
UNAME: The value of this variable is the default
sname. It is initialized to the user's login
name, if he has a disk directory, and to
MACSYM otherwise. UNAME determines to what
directory disk files will be written.
DSKALL: If TRUE will cause values, functions, arrays,
and rules to be written periodically to disk
in addition to labelled expressions. TRUE is
the default value whereas if DSKALL is FALSE
then only labelled expressions will be
written.
10.3 Explicit storage of expressions -- the SAVE and STORE com-
mands
A - Use of the commands
The SAVE and STORE commands allow the user to explicitly
state that certain expressions should be written onto disk. These
commands also allow him to specify the file into which these ex-
pressions should be written. They allow the user to store away
arrays, function definitions, rules, and any other kind of value.
The main purpose of these commands is to allow the user to save
expressions on disk so that they can be read into future MACSYMAs.
SAVE and STORE are identical in all respects but one.
When an expression is STORE'd it is both written on disk and
removed from core. (When the expression is referenced, of course,
the correct value is retrieved from disk.) When an expression is
SAVE'd, it is written on disk but not removed from core. The only
difference between these two commands is their effect on core
storage.
SAVE and STORE take any number of arguments. If the first
argument is a list it is assumed to be the file specification
(e.g. [fn1, fn2, device, useranme]). In accordance with the
standard options for file specifications, the latter arguments may
be omitted from the list and the default device and username will
be assumed. If the first argument is not a list, the expressions
will be written into a file with the default filename. The value
of the MACSYMA variable FILENAME is the default first filename,
and the value of the MACSYMA variable STORENUM is the default
second filename. The value of STORENUM is decreased first by 1
each time a file is written, so its value must always be numeric.
STORENUM is initially 0. The value of DEV is the default device,
and the value of UNAME is the default username.
All arguments to SAVE or STORE, except possibly the first,
must be one of the following:
Secondary Storage Commands page 10-4
1- The name of an "information structure" (see sect 7.10)
SAVE(VALUES) will not cause variables whose purpose is to
communicate with the system (e.g. NONCOMNONASSOC, RATPRINT) to be
saved.
2- ALL When this atom is an argument every quantity
associated with any information structure is written.
3- When any other atom is an argument, it must be either
an array, a function, or have a value. It gets written to disk.
4- A=B The effect is similar to the case where the argu-
ment is just B, i.e. B gets written to disk. The only difference
shows up if the file is read into some future MACSYMA. In that
case, the expression which is referred to as "B" in the present
MACSYMA will be referred to as "A" in the future MACSYMA. For
example, suppose I wish to save some expression, say D7, for use
in a future MACSYMA. I can execute STORE([FOO, BAR, DSK, ECR],
YESTERDAYSD7 = D7). D7 is now stored on disk. When I come back
the following day and load in a fresh MACSYMA I merely execute
LOADFILE(FOO, BAR, DSK, ECR) and the variable YESTERDAYSD7 will
take on the value which D7 had yesterday. This renaming however
has no effect on the present MACSYMA, where D7 must still be
referred to as "D7".
A command like STORE(LABELS); could cause difficulty if
the stored expressions are read into a future MACSYMA, because ex-
pressions referred to by linelabels will be lost when that
linelabel appears again in the future MACSYMA. Therefore when
reading such expressions into a fresh MACSYMA, the user should
either reset LINENUM, or INCHAR and OUTCHAR. He can assure that
this gets done automatically by executing a sequence such as
STORE(LABELS,INCHAR='F,OUTCHAR='G);
After the resultant disk file is read into a fresh MACSYMA, INCHAR
and OUTCHAR will automatically be changed into F and G
respectively.
The user should note that each use of the SAVE or STORE
command will cause exactly one file to be written, regardless of
the number of arguments the command is given.
REMFILE(TRUE) will do what REMFILE() does and in addition
will delete files created by SAVE or STORE which haven't been
assigned names explicitly by the user.
Certain MACSYMA variables (i.e. LINENUM, FILESIZE,
NONCOMNONASSOC, etc.) are used to communicate to the MACSYMA
system that certain options are in effect, or to tell the system
to use certain values. These variables should not be STORE'd
(though they may be SAVE'd), since the system programs will not be
able to correctly retrieve their values from disk. In general,
one should not attempt to STORE variables whose purpose is to
provide information to the system.
Secondary Storage Commands page 10-5
B- Retrieval of expressions which have been written to
disk
1- In the present MACSYMA
Expressions which are written on disk using the SAVE command
also reside in core, so the notion of retrieving them from disk in
the present MACSYMA is not applicable. Expressions written to
disk using STORE, however, no longer reside in core. When such
expressions are referenced the system will always retrieve the
correct value from disk. When a STORE'd array is referenced, the
array will be brought back to core. Functions and values will be
read from disk correctly, but will not be returned to core. If
the user wants to bring an expression back to core he may use the
command UNSTORE. This command takes any number of arguments.
Each argument must be an atom, and if this atom refers to an ex-
pression which is stored on disk, the expression is returned to
core. Of course, when an expression is UNSTORE'd, either by the
user or by the system (as happens when STORE'd arrays are
accessed), a copy of the expression still remains on disk in the
assigned file.
2- In future MACSYMAs
Files created by SAVE and STORE can be loaded into future
MACSYMAs using the LOADFILE command. This will set up in core all
those expressions which were written into the file. Some of the
expressions will have different names than they had in the MACSYMA
where they were created, if the renaming option (i.e. arguments of
the form A=B) of the STORE or SAVE command was used.
10.4 Saving a MACSYMA Overnight
Often a user in the middle of his work would like to save
everything on disk so he can go home and resume work tomorrow.
When the user decides to save the state of his MACSYMA, he should
execute
SAVE([WENT,HOME,DSK,USER],ALL);
This will write all his lines, arrays, functions, values, rules,
and aliases (if he has created any) into a single disk file. If
the user has been using the automatic storage scheme he should now
execute REMFILE(); to delete useless files from disk. When the
user comes back the next day be should load a fresh MACSYMA and
execute one of the following two commands:
LOADFILE(WENT,HOME,DSK,USER);
RESTORE(WENT,HOME,DSK,USER);
The former command will cause all the expressions from yesterday
to be loaded into today's MACSYMA. Note that whereas all the
expressions may have fit into the MACSYMA in which they were
generated, they may not fit into a new MACSYMA. This is because
Secondary Storage Commands page 10-6
common subexpressions were originally shared. The RESTORE command
does not cause the expressions to be loaded into core but does
permit them to be accessed when needed. Thus it should be used if
it is not desired to bring all the expressions into core at the
same time.
Plotting Commands page 11-1
11.0 Plotting Commands
The MACSYMA commands PLOT and GRAPH produce character plots
of specified functions and sets of data points. (They can also be
used to produce output files for plotting on the Calcomp plotter
attached to the PDP-10 used by the Artificial Intelligence Group).
The format of these commands and the variables used by the
corresponding routines are described below:
Variables
LINEL - width of graphing area in terms of number of characters.
default values: 68 for DATAPOINT
88 for IMLAC
79 for hard copy devices
SCOPEHEIGHT - height of graph in terms of number of characters.
default values: 24 for DATAPOINT and hard copy devices
38 for IMLAC
CALCOMP [FALSE] - if set to TRUE will cause the output of a file
for use on the Calcomp plotter. The file is output on
DEV:UNAME;FILENAME FILENUM+1, the variables of which can be
set by the user. (see sect 10.2).
AXIS [FALSE] - if set to TRUE will cause the X=0 axis to be dis-
played.
Formats for PLOT
PLOT(F(x),x,low,high)
Plots the expression F(x) over the domain low < x <
high.
PLOT (F(x),x,low,high,INTEGER)
As above, but plots F(x) only for integer values of x.
PLOT (F(x),x,[x1,x2,x3,...,xn])
Plots the function F(x) for the values x1,x2,x3,...,xn.
The first argument to PLOT may also be a list of functions rather
than just a single function. This permits several functions
to be plotted on the same set of axes. An optional final
argument may be a list of plotting characters used for the
given function(s) and these are to be enclosed in ?'s. (Note
also that if a special symbol such as ; , $ , etc. is used it
must be preceded by a \.) An * will be used to plot any
Plotting Commands page 11-2
functions which are not given a particular plotting
character.
FORMATS FOR GRAPH:
GRAPH ([x1,x2,x3,...,xn],[y1,y2,y3,...,yn],xlabel,ylabel)
Graphs the two sets of data points with the specified
labels. The labels may be omitted.
GRAPH ([[x1,y1],[x2,y2],[x3,y3],...,[xn,yn]],xlabel,ylabel)
Graphs the points specified by the list of coordinate
pairs. Again, the labels may be omitted.
The graphs produced by the above functions is a character
plot on a coordinate system defined by axes along the minimum x
and y values of the plot. The x and y coordinates are
independently scaled to optimally use the specified graphing area.
Note that this may distort the shape of the graph e.g., a circle
could become an ellipse. The origin of the graph (left-hand
corner) is given on the graph by the values of XORG and YORG; the
computed increments (= one character) are given by the values of
XDELTA and YDELTA. The axes are labeled with the number sequence
0,2,4,6,8,0,2,4,... as an aid in counting the number of
increments from the origin.
When a graph is completed, the user must type a single
character, such as space or carriage return, to return control to
MACSYMA. On a display-type console this causes the screen to be
cleared for further MACSYMA commands.
Plotting Commands page 11-3
Examples
(C1) PLOT([SQRT(1-X**2),X**2],X,-1.0,1.0,["\@"]);
Y 6[
D [
E 4[
L [ * @@@@@@@@@@@ *
T 2[ @@ @@@
A [ @@@ @@ *
0[ * @ @@
= [ @@ @
8[ * @ @ *
3 [ @ @@
. 6[ * @ @ *
1 [ @
E 4[ @ @ *
- [ * @
2 2[ @ @*
[ @
0[ *@
[ @ *
8[ * * @
[ @
6[ * * @
[ *
4[ @ *
[ * * @
2[ *
[ @ *
0[ * * @
[ *
8[ * *
[ * *
6[ @ * *
[ * *
4[ ** *
[ * **
2[ *** **
[ ****** @
0-------------------------------------------------------
0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2
YORG=0.0 XORG=-1.014 XDELTA=3.9E-2
(D1) DONE
Plotting Commands page 11-4
(C2) POLARPLOT(RHO, NUMBREV) := BLOCK([THETA, LIMIT, X, Y, NUMER, RATPRINT],
NUMER:TRUE, RATPRINT:FALSE, THETA:0.0, X:[], Y:[],
LIMIT:72*NUMBREV, FOR I:1 THRU LIMIT DO
BLOCK([P],P:RHO(THETA), X:CONS(P*COS(THETA),X),
Y:CONS(P*SIN(THETA), Y), THETA:THETA + %PI/36.0), GRAPH(X, Y, X, Y))$
(C3) F(T):=1+SIN(.5*T)*COS(T)$
(C4) POLARPLOT(F,2);
Y [
D 2[
E [ * * * * *
L 0[ * * * * * * * *
T [ * * * * *
A 8[ *** *
= [ * * * *
8 6[ * * *
. [ * ** *
1 4[ * * * *
E [ * **
- 2[ * * ** *
2 [ * ** *
0[ * * ** *
[ * *
8[ * ** * *
[ * **
6[ * ** *
[ * **
4[ * ** * *
Y [ * *
2[ * * ** *
[ * ** *
0[ * * ** *
[ * **
8[ * * * *
[ * ** *
6[ * * *
[ * * * *
4[ *** *
[ * * * * *
2[ * * * * * * * *
[ * * * * *
0[
-----------------------------------------------------------
0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6
YORG=-1.296 XORG=-2.052 XDELTA=5.7E-2
X
Debugging page 12-1
12.0 Debugging in MACSYMA
When the user's commands, especially functions and BLOCK pro-
grams, do not do what he expected or generate errors, MACSYMA
offers him several debugging alternatives:
(1) He may trace any of his function calls by typing
TRACE(fun1,fun2,...), where the funi are either MACSYMA or
user-defined functions. This will cause a printout of the
function name and its arguments each time it is entered; and of
the function name and the value it returns each time it is exited.
A count which is the level of recursion is also printed. Usually,
this is all the tracing power the user will need, although MACSYMA
offers him the full capabilities of the LISP tracing package
including conditional and breakpoint tracing. This will not be
described here - for information see the A.I. Lab LISP Interim
Report (A.I. Memo 190), Appendix D. MACSYMA uses trace-syntax very
similar to that of LISP.
To check which functions are currently under trace, the user
may type TRACE(). To remove tracing of functions use
UNTRACE(fun1,fun2,...). To untrace all previous traced functions
type UNTRACE(). Since the TRACE package takes up some of the
user's workspace in core, when he is finished with it he should
type REMTRACE(). He may always reload it at a later time.
(2) By setting the variable DEBUG to TRUE, the user will be
informed when each of his variables which has a value comes up for
evaluation for the first time during the course of a computation.
This has a dual purpose. The user will be informed of evaluations
he may not have been aware of which are the result of assignments
he made long ago. It also gives him a sort of chronological trace
of his computations which may be helpful in finding out where an
error has occurred.
(3) By setting the variable PREDERROR to TRUE, the user will
be informed of predicates of IF-THEN-ELSE statements which failed
to evaluate to either TRUE or FALSE. This happens automatically
in the midst of BLOCK programs and DO statements.
(4) The user may have variables which he intends not to use
purely symbolically, i.e. they are to have values all the time.
By typing BINDTEST(var1,var2,...) MACSYMA will give the user an
error whenever any of the vari appear in a computation unbound.
To remove a BINDTEST declaration, the user may use the function
REMOVE. (see section 7.10)
(5) When an error occurs in the course of a computation,
MACSYMA prints out an error message and terminates the computa-
tion. At times the user may find it helpful to investigate the
environment at the place of the error. To do so he may type
Debugging page 12-2
DEBUGMODE(TRUE) and repeat his computation. This enters a special
debugging mode which will "break" or pause when an error occurs.
This mode may be terminated by typing DEBUGMODE(FALSE). When an
error occurs in debugging mode, (ERROR-BREAK) is printed. MACYSMA
is then waiting for the user to type something. He may type any
command just as if he were at "top level". The commands will be
evaluated in the environment of the error. If the user types
BACKTRACE;, MACSYMA will print out a backtrace, which is a list of
the function calls the user is currently in together with the
arguments they were called with, ordered from most recent to
earliest i.e., when reversed, this list shows a trace beginning
from the initial command and ending at the last call entered
including only those function calls from which the user still has
not exited. (For those users who know LISP, one may type
control-H and enter a similar LISP break-loop. When altmode-P
space is typed, thus exiting from the LISP break-loop, the MACSYMA
break-loop is re-entered.) To exit from the MACSYMA error-break
and return to "top-level", type EXIT;.
The user may also enter the error-break at any point, by
typing control-A. This will simply cause his computation to
pause, while he investigates at will. %% refers to the last
computed result while in the MACSYMA break. % still refers to the
last result computed at top-level. Upon typing EXIT;, the
computation will resume.
During a break one may type TOPLEVEL;. This will cause
top-level MACSYMA to be entered recursively. Labels will now be
bound as usual. Everything will be identical to the previous
top-level state except that the computation which was interrupted
is saved. The command TOBREAK() will cause the break which was
left by typing TOPLEVEL; to be re-entered. If TOBREAK is given
any argument whatsoever, then the break will be exited, which is
equivalent to typing TOBREAK() immediately followed by EXIT;.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Appendix I - MACSYMA's Grammar
Following is a condensed version of the grammar for
MACSYMA's input expressions. Note that an expression, though
syntactically correct, may not be meaningful as in F(X):1.
(This will give the message "IMPROPER VALUE ASSIGNMENT MSET" if
typed to MACSYMA.)
The following notation is used. Braces with a subscript of
0 mean that one or none of the quantities enclosed are to be
chosen. Braces without a subscript mean that exactly one of the
enclosed quantities is to be chosen.
Here, a line typed to MACSYMA is called a Sentence. This
is the starting symbol for the grammar and is defined below in
terms of successively smaller parts until finally reaching a
terminal quantity. A terminal symbol is written entirely in
capital letters while only the first letter of a non-terminal
symbol is capitalized.
This BNF-like notation is used only for historical reasons.
MACSYMA actually uses a parser the idea for which came from V.R.
Pratt. (See A.I. Memo 277. Feb 1973)
- - - - - - - - - - - - - - - - - - - - - - - - -
1. Sentence ->
(a) Statement
(b) Statement, Statement, ... , Statement
- - - - - - - - - - - - - - - - - - - - - - - - -
2. Statement ->
(a) Expression
:
(b) Qfunction :: Expression
:=
- - - - - - - - - - - - - - - - - - - - - - - - -
3. Expression ->
(a) []
(b) Grelation
(c) Grelation OR Expression
(d) IF Expression THEN Statement { ELSE Statement }
(e) FOR Quantity IN [Arglist]
THRU Statement
WHILE Expression DO Statement
UNLESS Expression
(f) FOR {Quantity : Expression} STEP Expression
NEXT Expression
THRU Statement
WHILE Expression DO Statement
UNLESS Expression
(g) NOT Expression
- - - - - - - - - - - - - - - - - - - - - - - - -
4. Grelation ->
(a) Relation
(b) Grelation AND Relation
- - - - - - - - - - - - - - - - - - - - - - - - -
5. Relation ->
(a) Sum
<
>
(b) Sum = Sum
<=
>=
- - - - - - - - - - - - - - - - - - - - - - - - -
6. Sum ->
(a) - Term
+
(b) Sum + Term
-
- - - - - - - - - - - - - - - - - - - - - - - - -
7. Term ->
(a) Factor
(b) Factor . Term
(c) Term * Factor
/
- - - - - - - - - - - - - - - - - - - - - - - - -
8. Factor ->
(a) Base
(b) Base ** Factor
↑
- - - - - - - - - - - - - - - - - - - - - - - - -
9. Base ->
(a) Base !
!!
(b) ' ' Qfunction
'
(c) (Arglist)
- - - - - - - - - - - - - - - - - - - - - - - - -
10. Qfunction ->
(a) Quantity ( )
(Arglist)
- - - - - - - - - - - - - - - - - - - - - - - - -
11. Quantity ->
(a) {Atom} {[Arglist]}
- - - - - - - - - - - - - - - - - - - - - - - - -
12. Arglist ->
(a) Statement
(b) Statement, Statement, ... , Statement
- - - - - - - - - - - - - - - - - - - - - - - - -
13. Atom -> (see sect. 3.1 and 3.2)
(a) Integer
(b) Floating-point-number
(c) Name
Appendix II - Illustrative Examples
This appendix shows a complete interaction with MACSYMA.
An ordinary second-order differential equation is solved by two
methods. First by using pattern matching and solving the
characteristic equation and then by using laplace transforms.
(C1) BATCH(SOLDER,DEMO,DSK,DEMO);
(C1) /* THE FOLLOWING ROUTINE RETURNS THE HOMOG.-PART SOLN.
TO 2ND ORDER LINEAR DIFF'L EQNS. WITH CONST. COEFFS. */
MATCHDECLARE(B,RATNUM)$
MATCOM FASL DSK MACSYM BEING LOADED
LOADING DONE
(C2) MATCHDECLARE(C,RATNUM)$
(C3) MATCHDECLARE(F,FREEOF(U))$
(C4) ALIAS(D,DIFF)$
(C5) DEFMATCH(SOLDE,'D(U,X,2) + B*'D(U,X) + C*U = F,U,X)$
(C6) SOLDER(EQN,U,X) :=
BLOCK([B,C,F,DISC,R1,R2,ALPHA,BETA],
IF SOLDE(EQN,U,X) = FALSE THEN RETURN(FALSE),
DISC: B↑2 - 4*C, ALPHA: -B/2,
IF DISC=0 THEN RETURN(%E↑(ALPHA*X)*(A1+A2*X)),
BETA: SQRT(DISC)/2,
IF DISC > 0
THEN [R1: ALPHA + BETA, R2: ALPHA - BETA,
RETURN(A1*%E↑(R1*X) + A2*%E↑(R2*X))]
ELSE [BETA: SQRT(-1)*BETA,
RETURN(%E↑(ALPHA*X) * (A1*COS(BETA*X)
+ A2*SIN(BETA*X)))])$
(C7) /* AN EXAMPLE - THE METHOD OF UNDETERMINED COEFFS. FOR
OBTAINING THE PARTICULAR SOLN. AS WELL */
/* SUPRESS QUOTIENT DISPLAY OF NEGATIVE EXPONENTS */
EXPTDISPFLAG: FALSE$
(C8) DE: 'D(Y,X,2) - 'D(Y,X) - 6*Y = SIN(X);
2
D Y DY
(D8) --- - -- - 6 Y = SIN(X)
2 DX
DX
(C9) YH(X) := ''(SOLDER(%,Y,X));
- 2 X 3 X
(D9) YH(X) := A2 %E + A1 %E
(C10) YP(X) := B1*SIN(X) + B2*COS(X)$
(C11) YG(X) := YH(X) + YP(X)$
(C12) PLUGIN: EV(DE,DIFF,EXPAND,Y=YP(X));
(D12) B2 SIN(X) - 7 B1 SIN(X) - 7 B2 COS(X) - B1 COS(X)
= SIN(X)
(C13) EQN1: COEFF(PLUGIN,SIN(X));
(D13) B2 - 7 B1 = 1
(C14) EQN2: COEFF(PLUGIN,COS(X));
(D14) - 7 B2 - B1 = 0
(C15) GLOBALSOLVE: TRUE$
(C16) SOLN: SOLVE([EQN1,EQN2],[B1,B2]);
SOLUTION
7
(E16) B1 : - --
50
1
(E17) B2 : --
50
(D17) [E16, E17]
(C18) YG(X);
7 SIN(X) COS(X) 3 X - 2 X
(D18) - -------- + ------ + A1 %E + A2 %E
50 50
(C19) /* PLUGGING IN INITIAL CONDITIONS OF Y(0)=1
AND Y'(0)=0 */
EQN1: YG(0) = 1;
1
(D19) A2 + A1 + -- = 1
50
(C20) DIFF(YG(X),X);
SIN(X) 7 COS(X) 3 X - 2 X
(D20) - ------ - -------- + 3 A1 %E - 2 A2 %E
50 50
(C21) EQN2: EV(%,X=0) = 0;
7
(D21) - 2 A2 + 3 A1 - -- = 0
50
(C22) SOLN: SOLVE([EQN1,EQN2],[A1,A2]);
SOLUTION
21
(E22) A1 : --
50
14
(E23) A2 : --
25
(D23) [E22, E23]
(C24) YG(X);
3 X - 2 X
7 SIN(X) COS(X) 21 %E 14 %E
(D24) - -------- + ------ + -------- + -----------
50 50 50 25
(C25) /* RESETTING OF OPTIONS */
EXPTDISPFLAG: TRUE$
(C26) GLOBALSOLVE: FALSE$
(D27) BATCH DONE
(C28) "SOLUTION BY LAPLACE TRANSFORMS"$
(C29) SUBST(Y(X),Y,D8);
2
D D
(D29) --- Y(X) - -- Y(X) - 6 Y(X) = SIN(X)
2 DX
DX
(C30) LAPLACE(%,X,S);
LAPLAC FASL DSK MACSYM BEING LOADED
LOADING DONE
2
(D30) S LAPLACE(Y(X), X, S) - S LAPLACE(Y(X), X, S)
1
- 6 LAPLACE(Y(X), X, S) + ( - Y - S Y ) + Y = ------
1 0 0 2
S + 1
(C31) D30,Y[0]=1,Y[1]=0,EVAL;
2
(D31) S LAPLACE(Y(X), X, S) - S LAPLACE(Y(X), X, S)
1
- 6 LAPLACE(Y(X), X, S) - S + 1 = ------
2
S + 1
(C32) LINSOLVE([%],['LAPLACE(Y(X),X,S)]);
SOLUTION
3 2
S - S + S
(E32) LAPLACE(Y(X), X, S) = ----------------------
4 3 2
S - S - 5 S - S - 6
(D32) [E32]
(C33) ILT(E32,S,X);
3 X
7 SIN(X) COS(X) 21 %E 14
(D33) Y(X) = - -------- + ------ + -------- + --------
50 50 50 2 X
25 %E
βββββββββββββββββ
Index of Forms and Concepts
Arrays . . . . . . . . . . . . . . . . . 3-5
Assignment . . . . . . . . . . . . . . . 3-2
Blocks . . . . . . . . . . . . . . . . . 3-12
Breaking Execution . . . . . . . . . . . 5-1
Complex Arithmetic . . . . . . . . . . . 6-4
Constants . . . . . . . . . . . . . . . 6-1
Continued Fractions . . . . . . . . . . 7.5-6
Control Keys . . . . . . . . . . . . . . 5-1
CRE Form . . . . . . . . . . . . . . . . 4-1, 7.6-1
DDT . . . . . . . . . . . . . . . . . . 2-1, 5-2
Debugging . . . . . . . . . . . . . . . 7.13-1, 12-1
Differentiation . . . . . . . . . . . . 7.1-10
DO Statement
Editing . . . . . . . . . . . . . . . . 8-1
Equations . . . . . . . . . . . . . . . 3-10
Evaluation . . . . . . . . . . . . . . . 4-2, 7.1-1
Extended Rational Function Form . . . . 4-2, 7.6-4
Factoring . . . . . . . . . . . . . . . 7.1-9
Files . . . . . . . . . . . . . . . . . 5-2
Functions . . . . . . . . . . . . . . . 3-3, 4-2
FOR Statement . . . . . . . . . . . . . See DO Statement
Garbage Collection . . . . . . . . . . . 5-1
Graphing . . . . . . . . . . . . . . . . 11-1
IF Statement . . . . . . . . . . . . . . 3-11
Imaginary Numbers . . . . . . . . . . . 6-4
Information Structures . . . . . . . . . 7.10-7
Integration . . . . . . . . . . . . . . 7.1-12
ITS . . . . . . . . . . . . . . . . . . 1-1, 2-1
Laplace Transforms . . . . . . . . . . . 7.5-2
Limits . . . . . . . . . . . . . . . . . 7.5-1
LISP . . . . . . . . . . . . . . . . . . 1-1, 2-2, 4-1, 5-1,2
Lists . . . . . . . . . . . . . . . . . 3-7
Login and Logout . . . . . . . . . . . . 2-1
Mathematical Functions . . . . . . . . . 6-1
Matrices . . . . . . . . . . . . . . . . 3-8, 4-1, 7.4-1
Names . . . . . . . . . . . . . . . . . 3-1,2
Non-commutative multiplication . . . . . 3-3
Noun Functions . . . . . . . . . . . . . 4-3
Numbers . . . . . . . . . . . . . . . . 3-1
Operators . . . . . . . . . . . . . . . 3-3
Pattern Matching . . . . . . . . . . . . 7.8-1
Plotting . . . . . . . . . . . . . . . . See Graphing
Power Series . . . . . . . . . . . . . . 7.5-4
Programs . . . . . . . . . . . . . . . . See Blocks
Quoted Strings . . . . . . . . . . . . . 3-1
Representation . . . . . . . . . . . . . 4-1
Series . . . . . . . . . . . . . . . . . See Power Series
Simplification . . . . . . . . . . . . . 4-2, 7.1-1
Solving Equations . . . . . . . . . . . 7.3-2
Subscripted Functions . . . . . . . . . 3-6
Substitution . . . . . . . . . . . . . . 7.2-3
Verb Functions . . . . . . . . . . . . . 4-2
Index of Functions and Commands
%TH . . . . . . . . . . . . . . . . . . 7.10-2, 9-3
ABS . . . . . . . . . . . . . . . . . . 6-2
ACOS . . . . . . . . . . . . . . . . . . 6-3
ACOSH . . . . . . . . . . . . . . . . . 6-3
ACOT . . . . . . . . . . . . . . . . . . 6-3
ACOTH . . . . . . . . . . . . . . . . . 6-3
ACSC . . . . . . . . . . . . . . . . . . 6-3
ACSCH . . . . . . . . . . . . . . . . . 6-3
ADDROW . . . . . . . . . . . . . . . . . 7.4-1
ALGSYS . . . . . . . . . . . . . . . . . 7.3-2
ALIAS . . . . . . . . . . . . . . . . . 7.10-3
ALLROOTS . . . . . . . . . . . . . . . . 7.3-1
APPEND . . . . . . . . . . . . . . . . . 7.11-1
APPLY . . . . . . . . . . . . . . . . . 7.11-1
APPLY1 . . . . . . . . . . . . . . . . . 7.8-3
APPLY2 . . . . . . . . . . . . . . . . . 7.8-3
ARRAY . . . . . . . . . . . . . . . . . 3-5
ASEC . . . . . . . . . . . . . . . . . . 6-3
ASECH . . . . . . . . . . . . . . . . . 6-3
ASIN . . . . . . . . . . . . . . . . . . 6-3
ASINH . . . . . . . . . . . . . . . . . 6-3
ASSUME . . . . . . . . . . . . . . . . . 7.12-1
ATAN . . . . . . . . . . . . . . . . . . 6-3
ATANH . . . . . . . . . . . . . . . . . 6-3
ATOM . . . . . . . . . . . . . . . . . . 7.7-1
AUGCOEFMATRIX . . . . . . . . . . . . . 7.4-2
BAKSOLVE . . . . . . . . . . . . . . . . 7.3-4
BATCH . . . . . . . . . . . . . . . . . 9-1
BATCON . . . . . . . . . . . . . . . . . 9-2
BERN . . . . . . . . . . . . . . . . . . 6-2
BERNPOLY . . . . . . . . . . . . . . . . 7.5-7
BETA . . . . . . . . . . . . . . . . . . 6-2
BINDTEST . . . . . . . . . . . . . . . . 7.13-1, 12-1
BINOMIAL . . . . . . . . . . . . . . . . 6-2
BLOCK . . . . . . . . . . . . . . . . . 3-12
BOTHCASES . . . . . . . . . . . . . . . 3-1, 7.10-7
BREAK
CF . . . . . . . . . . . . . . . . . . . 7.5-6
CFDISREP . . . . . . . . . . . . . . . . 7.5-6
CFEXPAND . . . . . . . . . . . . . . . . 7.5-6
CHARPOLY . . . . . . . . . . . . . . . . 7.4-3
CLOSEFILE . . . . . . . . . . . . . . . 7.10-5
COEFF . . . . . . . . . . . . . . . . . 7.2-6
COEFMATRIX . . . . . . . . . . . . . . . 7.4-2
COL . . . . . . . . . . . . . . . . . . 7.4-2
COMPILE . . . . . . . . . . . . . . . . 7.10-2
CONS . . . . . . . . . . . . . . . . . . 7.11-1
CONSTANT . . . . . . . . . . . . . . . . 7.7-1
CONTENT . . . . . . . . . . . . . . . . 7.6-3
COPYMATRIX . . . . . . . . . . . . . . . 3-9, 7.4-1
COS . . . . . . . . . . . . . . . . . . 6-3
COSH . . . . . . . . . . . . . . . . . . 6-3
COT . . . . . . . . . . . . . . . . . . 6-3
COTH . . . . . . . . . . . . . . . . . . 6-3
CSC . . . . . . . . . . . . . . . . . . 6-3
CSCH . . . . . . . . . . . . . . . . . . 6-3
DEBUGMODE . . . . . . . . . . . . . . . 7.13-1, 12-2
DEFINE . . . . . . . . . . . . . . . . . 4-6, 7.10-2
DEFMATCH . . . . . . . . . . . . . . . . 7.8-1
DEFRULE . . . . . . . . . . . . . . . . 7.8-3
DEFTAYLOR . . . . . . . . . . . . . . . 7.5-5
DELETE . . . . . . . . . . . . . . . . . 7.2-8
DEMO . . . . . . . . . . . . . . . . . . 9-2
DERIVDEGREE . . . . . . . . . . . . . . 7.2-7
DEPENDENCIES . . . . . . . . . . . . . . 7.1-10
DETERMINANT . . . . . . . . . . . . . . 7.4-3
DIAGMATRIX . . . . . . . . . . . . . . . 7.4-2
DIFF . . . . . . . . . . . . . . . . . . 7.1-10
DISP . . . . . . . . . . . . . . . . . . 7.10-6
DISPFUN . . . . . . . . . . . . . . . . 7.10-2
DISPLAY . . . . . . . . . . . . . . . . 7.10-6
DISPRULE . . . . . . . . . . . . . . . . 7.10-2
DISPTERMS . . . . . . . . . . . . . . . 7.10-6
DIVIDE . . . . . . . . . . . . . . . . . 7.6-2
DPART . . . . . . . . . . . . . . . . . 7.2-3
DSKGC . . . . . . . . . . . . . . . . . 7.10-4, 10-1
ECHELON . . . . . . . . . . . . . . . . 7.4-2
EMATRIX . . . . . . . . . . . . . . . . 7.4-2
ENDCONS . . . . . . . . . . . . . . . . 7.11-1
ENTERMATRIX . . . . . . . . . . . . . . 7.4-1
ENTIER . . . . . . . . . . . . . . . . . 6-2
ERAT . . . . . . . . . . . . . . . . . . 7.6-4
ERROR . . . . . . . . . . . . . . . . . 7.10-2
EULER . . . . . . . . . . . . . . . . . 6-2
EV . . . . . . . . . . . . . . . . . . . 7.1-1
EXIT . . . . . . . . . . . . . . . . . . 7.13-1, 12-2
EXP . . . . . . . . . . . . . . . . . . 6-2
EXPAND . . . . . . . . . . . . . . . . . 7.1-3
FACTOR . . . . . . . . . . . . . . . . . 7.1-9
FIBB . . . . . . . . . . . . . . . . . . 6-2
FIRST . . . . . . . . . . . . . . . . . 7.2-8
FLOATNUM . . . . . . . . . . . . . . . . 7.7-1
FORGET . . . . . . . . . . . . . . . . . 7.13-1
FREEOF . . . . . . . . . . . . . . . . . 7.8-1
GAMMA . . . . . . . . . . . . . . . . . 6-2
GCD . . . . . . . . . . . . . . . . . . 7.6-3
GENFACT . . . . . . . . . . . . . . . . 6-2
GENMATRIX . . . . . . . . . . . . . . . 7.4-1
GET . . . . . . . . . . . . . . . . . . 7.11-3
GETVAR . . . . . . . . . . . . . . . . . 7.6-2
GFACTOR . . . . . . . . . . . . . . . . 7.1-10
GO . . . . . . . . . . . . . . . . . . . 3-13
GRADEF . . . . . . . . . . . . . . . . . 7.1-11
GRAPH . . . . . . . . . . . . . . . . . 7.9-1
HIPOW . . . . . . . . . . . . . . . . . 7.2-7
IDENT . . . . . . . . . . . . . . . . . 7.4-2
ILT . . . . . . . . . . . . . . . . . . 7.5-2
IMAGPART . . . . . . . . . . . . . . . . 7.2-7
INPART . . . . . . . . . . . . . . . . . 7.2-2
INTEGER . . . . . . . . . . . . . . . . 7.7-1
INTEGRATE . . . . . . . . . . . . . . . 7.1-12
IS . . . . . . . . . . . . . . . . . . . 7.13-1
KILL . . . . . . . . . . . . . . . . . . 3-5, 7.10-3
LAMBDA . . . . . . . . . . . . . . . . . 3-7, 7.4-4, 7.11-1
LAPLACE . . . . . . . . . . . . . . . . 7.5-2
LAST . . . . . . . . . . . . . . . . . . 7.2-8
LENGTH . . . . . . . . . . . . . . . . . 7.2-8
LET . . . . . . . . . . . . . . . . . . 7.8-4
LETSIMP . . . . . . . . . . . . . . . . 7.8-4
LHS . . . . . . . . . . . . . . . . . . 7.2-7
LIMIT . . . . . . . . . . . . . . . . . 7.5-1
LINSOLVE . . . . . . . . . . . . . . . . 7.3-2
LISTP . . . . . . . . . . . . . . . . . 7.1-1
LOADFILE . . . . . . . . . . . . . . . . 7.10-4
LOG . . . . . . . . . . . . . . . . . . 6-2
LOGOUT . . . . . . . . . . . . . . . . . 7.10-4
LOPOW . . . . . . . . . . . . . . . . . 7.2-7
MAKECONSTANT . . . . . . . . . . . . . . 7.10-2
MAP . . . . . . . . . . . . . . . . . . 7.11-1
MAPLIST . . . . . . . . . . . . . . . . 7.11-2
MATCHDECLARE . . . . . . . . . . . . . . 7.8-1
MATRIX . . . . . . . . . . . . . . . . . 3-8, 7.4-1
MATRIXMAP . . . . . . . . . . . . . . . 7.4-4
MATRIXP . . . . . . . . . . . . . . . . 7.7-1
MAX . . . . . . . . . . . . . . . . . . 6-2
MEMBER . . . . . . . . . . . . . . . . . 7.11-1
MIN . . . . . . . . . . . . . . . . . . 6-2
MINOR . . . . . . . . . . . . . . . . . 7.4-2
MOD . . . . . . . . . . . . . . . . . . 7.6-3
MODEDECLARE . . . . . . . . . . . . . . 7.10-1
MULTTHRU . . . . . . . . . . . . . . . . 7.1-4
NOUN . . . . . . . . . . . . . . . . . . 4-3,5
NROOTS . . . . . . . . . . . . . . . . . 7.3-1
NULL . . . . . . . . . . . . . . . . . . 7.11-1
NUMBER . . . . . . . . . . . . . . . . . 7.7-1
NUMFACTOR . . . . . . . . . . . . . . . 7.2-6
PAGEPAUSE . . . . . . . . . . . . . . . 7.10-6
PART . . . . . . . . . . . . . . . . . . 7.2-2
PARTFRAC . . . . . . . . . . . . . . . . 7.11-8
PLAYBACK . . . . . . . . . . . . . . . . 7.10-5
PLOT . . . . . . . . . . . . . . . . . . 7.9-1
POLYSIGN . . . . . . . . . . . . . . . . 6-2
POWERSERIES . . . . . . . . . . . . . . 7.5-4
PRINDISPLAY . . . . . . . . . . . . . . 7.10-6
PRINT . . . . . . . . . . . . . . . . . 7.10-6
PRINVARLIST . . . . . . . . . . . . . . 7.6-1
PRODUCT . . . . . . . . . . . . . . . . 7.1-14
PS . . . . . . . . . . . . . . . . . . . 7.6-4
PSI . . . . . . . . . . . . . . . . . . 6-2
PUT . . . . . . . . . . . . . . . . . . 7.11-2
QPUT . . . . . . . . . . . . . . . . . . 7.11-2
QUIT . . . . . . . . . . . . . . . . . . 7.10-4
QUNIT . . . . . . . . . . . . . . . . . 7.5-6
QUOTIENT . . . . . . . . . . . . . . . . 7.6-2
RADCAN . . . . . . . . . . . . . . . . . 7.1-7
RANK . . . . . . . . . . . . . . . . . . 7.4-3
RAT . . . . . . . . . . . . . . . . . . 7.6-1
RATCOEF . . . . . . . . . . . . . . . . 7.2-6
RATDENOM . . . . . . . . . . . . . . . . 7.6-2
RATDIFF . . . . . . . . . . . . . . . . 7.1-4
RATDISREP . . . . . . . . . . . . . . . 7.7-1
RATEXPAND . . . . . . . . . . . . . . . 7.6-2
RATNUM . . . . . . . . . . . . . . . . . 7.7-1
RATNUMER . . . . . . . . . . . . . . . . 7.6-2
RATP . . . . . . . . . . . . . . . . . . 7.7-1
RATSIMP . . . . . . . . . . . . . . . . 7.1-5
RATSUBST . . . . . . . . . . . . . . . . 7.2-4
RATVARS . . . . . . . . . . . . . . . . 7.6-1
READ . . . . . . . . . . . . . . . . . . 7.10-6
REALPART . . . . . . . . . . . . . . . . 7.2-7
REALROOTS . . . . . . . . . . . . . . . 7.3-1
REM . . . . . . . . . . . . . . . . . . 7.11-3
REMAINDER . . . . . . . . . . . . . . . 7.6-2
REMALIAS . . . . . . . . . . . . . . . . 7.10-3
REMARRAY . . . . . . . . . . . . . . . . 7.10-3
REMFILE . . . . . . . . . . . . . . . . 7.10-4, 10-2
REMFUNCTION . . . . . . . . . . . . . . 7.10-2
REMLET . . . . . . . . . . . . . . . . . 7.8-5
REMOVE . . . . . . . . . . . . . . . . . 3-5, 7.10-3
REMOVERULE . . . . . . . . . . . . . . . 7.10-3
REMTRACE . . . . . . . . . . . . . . . . 7.13-1, 12-1
REMVALUE . . . . . . . . . . . . . . . . 3-5, 7.10-2
RETURN . . . . . . . . . . . . . . . . . 3-13,14,16
RESIDUE . . . . . . . . . . . . . . . . 7.5-1
REST . . . . . . . . . . . . . . . . . . 7.2-8
RESTORE . . . . . . . . . . . . . . . . 7.1-13
RESULTANT . . . . . . . . . . . . . . . 7.4-2
REVERSE . . . . . . . . . . . . . . . . 7.10-3, 10-3
RHS . . . . . . . . . . . . . . . . . . 7.2-8
RISCH . . . . . . . . . . . . . . . . . 7.1-13
ROW . . . . . . . . . . . . . . . . . . 7.4-2
SAVE . . . . . . . . . . . . . . . . . . 7.10-3, 10-3
SEC . . . . . . . . . . . . . . . . . . 6-3
SECH . . . . . . . . . . . . . . . . . . 6-3
SETELMX . . . . . . . . . . . . . . . . 7.4-2
SIGN . . . . . . . . . . . . . . . . . . 7.13-1
SIGNUM . . . . . . . . . . . . . . . . . 6-2
SIN . . . . . . . . . . . . . . . . . . 6-3
SINH . . . . . . . . . . . . . . . . . . 6-3
SOLVE . . . . . . . . . . . . . . . . . 7.3-2
SQFR . . . . . . . . . . . . . . . . . . 7.1-9
SQRT . . . . . . . . . . . . . . . . . . 6-2
SRRAT . . . . . . . . . . . . . . . . . 7.6-5
STORE . . . . . . . . . . . . . . . . . 7.10-3, 10-3
STRING . . . . . . . . . . . . . . . . . 7.10-5
STRINGOUT . . . . . . . . . . . . . . . 7.10-5
SUBMATRIX . . . . . . . . . . . . . . . 7.4-2
SUBSTINPART . . . . . . . . . . . . . . 7.2-5
SUBST . . . . . . . . . . . . . . . . . 7.2-3
SUBSTPART . . . . . . . . . . . . . . . 7.2-4
SUM . . . . . . . . . . . . . . . . . . 7.1-13
TAN . . . . . . . . . . . . . . . . . . 6-3
TANH . . . . . . . . . . . . . . . . . . 6-3
TAYLOR . . . . . . . . . . . . . . . . . 7.5-4
TELLSIMP . . . . . . . . . . . . . . . . 7.8-3
TELLSIMPAFTER . . . . . . . . . . . . . 7.8-3
TIME . . . . . . . . . . . . . . . . . . 7.10-4
TOBREAK . . . . . . . . . . . . . . . . 7.13-1, 12-2
TOPLEVEL . . . . . . . . . . . . . . . . 7.13-1, 12-2
TRACE . . . . . . . . . . . . . . . . . 7.13-1, 12-1
TRANSLATE . . . . . . . . . . . . . . . 7.10-1
TRANSPOSE . . . . . . . . . . . . . . . 7.4-2
TRIANGULARIZE . . . . . . . . . . . . . 7.4-3
TRIGEXPAND . . . . . . . . . . . . . . . 7.5-7
UNBOX . . . . . . . . . . . . . . . . . 7.2-3
UNSTORE . . . . . . . . . . . . . . . . 7.10-4
UNTRACE . . . . . . . . . . . . . . . . 7.13-1, 12-1
WRITEFILE . . . . . . . . . . . . . . . 7.10-5
XTHRU . . . . . . . . . . . . . . . . . 7.1-6
ZETA . . . . . . . . . . . . . . . . . . 6-2
Index of Constants, Switches, and Variables
% . . . . . . . . . . . . . . . . . . . 2-2, 3-1
%% . . . . . . . . . . . . . . . . . . . 7.13-1
ABSBOXCHAR
ALIASES . . . . . . . . . . . . . . . . 7.10-7
ARRAYS . . . . . . . . . . . . . . . . . 7.10-7
AXIS . . . . . . . . . . . . . . . . . . 11-1
BACKSUBSTOFF . . . . . . . . . . . . . . 7.3-2
BACKTRACE . . . . . . . . . . . . . . . 7.12-1, 12-2
BASE . . . . . . . . . . . . . . . . . . 7.10-9
BATCHKILL . . . . . . . . . . . . . . . 9-3
BATCOUNT . . . . . . . . . . . . . . . . 9-3
BERLEFACT . . . . . . . . . . . . . . . 7.1-9
BOXCHAR
BRANCH . . . . . . . . . . . . . . . . . 7.1-15
CALCOMP . . . . . . . . . . . . . . . . 11-1
CAUCHYSUM . . . . . . . . . . . . . . . 7.1-12
CFLENGTH . . . . . . . . . . . . . . . . 7.5-6
CURSOR . . . . . . . . . . . . . . . . . 7.10-8, 8-1
DEBUG . . . . . . . . . . . . . . . . . 7.13-1, 12-1
DEPENDENCIES . . . . . . . . . . . . . . 7.1-10, 7.10-7
DERIVATIVEABREV . . . . . . . . . . . . 7.1-10
DERIVFLAG . . . . . . . . . . . . . . . 7.1-10
DERIVLIST . . . . . . . . . . . . . . . 7.1-1
DETOUT . . . . . . . . . . . . . . . . . 7.4-5
DEV . . . . . . . . . . . . . . . . . . 10-2, 11-1
DIFF . . . . . . . . . . . . . . . . . . 7.1-10
DISPFLAG . . . . . . . . . . . . . . . . 7.10-8
DONTFACTOR . . . . . . . . . . . . . . . 7.1-8
DOSUM . . . . . . . . . . . . . . . . . 7.1-13
DSKALL . . . . . . . . . . . . . . . . . 10-3
DSKUSE . . . . . . . . . . . . . . . . . 10-1
%E . . . . . . . . . . . . . . . . . . . 6-1
%EMODE . . . . . . . . . . . . . . . . . 7.1-15
ERATCANON . . . . . . . . . . . . . . . 7.6-4
ERRORFUN
EVAL . . . . . . . . . . . . . . . . . . 7.1-1
EXPAND . . . . . . . . . . . . . . . . . 7.1-1
EXPON . . . . . . . . . . . . . . . . . 7.1-15
EXPONENTIALIZE . . . . . . . . . . . . . 7.1-15
EXPOP . . . . . . . . . . . . . . . . . 7.1-15
EXPTDISPFLAG . . . . . . . . . . . . . . 7.10-8
EXPTSUBST . . . . . . . . . . . . . . . 7.2-3
EZOFFSWITCH . . . . . . . . . . . . . . 7.6-3
FACTLIM . . . . . . . . . . . . . . . . 6-2, 7.1-15
FACTOR . . . . . . . . . . . . . . . . . 7.1-1
FACTORFLAG . . . . . . . . . . . . . . . 7.1-8
FALSE . . . . . . . . . . . . . . . . . 6-1
FILENAME . . . . . . . . . . . . . . . . 10-2, 11-1
FILENUM . . . . . . . . . . . . . . . . 10-2, 11-1
FILESIZE . . . . . . . . . . . . . . . . 10-1,2
FLOAT . . . . . . . . . . . . . . . . . 7.1-1,2
FUNCTIONS . . . . . . . . . . . . . . . 7.10-7
GCDOFF . . . . . . . . . . . . . . . . . 7.6-3
GCDSWITCH . . . . . . . . . . . . . . . 7.6-3
GENINDEX . . . . . . . . . . . . . . . . 7.1-13, 7.10-8
GLOBALSOLVE . . . . . . . . . . . . . . 7.2-3
GRADEFS . . . . . . . . . . . . . . . . 7.1-11, 7.10-7
GRINDSWITCH . . . . . . . . . . . . . . 7.2-3
%I . . . . . . . . . . . . . . . . . . . 6-1
IBASE . . . . . . . . . . . . . . . . . 7.10-9
INCHAR . . . . . . . . . . . . . . . . . 7.10-8
INF . . . . . . . . . . . . . . . . . . 6-1, 7.1-12, 7.5-1
INFINITY . . . . . . . . . . . . . . . . 6-1, 7.1-12, 7.5-1
INFLAG . . . . . . . . . . . . . . . . . 7.2-8
KEEPFLOAT . . . . . . . . . . . . . . . 7.6-1
LABELS . . . . . . . . . . . . . . . . . 7.10-7
LASTTIME . . . . . . . . . . . . . . . . 7.10-7
LETRAT . . . . . . . . . . . . . . . . . 7.8-4
LHOSPITALLIM . . . . . . . . . . . . . . 7.5-1
LINECHAR . . . . . . . . . . . . . . . . 7.10-8
LINEL . . . . . . . . . . . . . . . . . 7.10-9, 11-1
LINENUM . . . . . . . . . . . . . . . . 7.10-8
LISTARITH . . . . . . . . . . . . . . . 3-8
LOGSIMPOFF . . . . . . . . . . . . . . . 7.1-15
LTRANSNAME . . . . . . . . . . . . . . . 7.5-2
MATCHDECLARES . . . . . . . . . . . . . 7.8-1
MATMUL . . . . . . . . . . . . . . . . . 7.1-1
MAXAPPLYDEPTH . . . . . . . . . . . . . 7.8-3
MAXNEGEX . . . . . . . . . . . . . . . . 7.1-13
MAXPOSEX . . . . . . . . . . . . . . . . 7.1-13
MINF . . . . . . . . . . . . . . . . . . 6-1, 7.1-12, 7.5-1
MODULUS . . . . . . . . . . . . . . . . 7.6-3
NOLABELS . . . . . . . . . . . . . . . . 7.10-8
NONCOMEXPT . . . . . . . . . . . . . . . 7.1-15
NONCOMNONASSOC . . . . . . . . . . . . . 7.1-15
NORAT . . . . . . . . . . . . . . . . . 7.4-5
NOSTAR . . . . . . . . . . . . . . . . . 7.10-8
NOUNDISP . . . . . . . . . . . . . . . . 7.10-8
NUMER . . . . . . . . . . . . . . . . . 6-1, 7.1-1,2
OUTCHAR . . . . . . . . . . . . . . . . 7.10-8
OUTSUM . . . . . . . . . . . . . . . . . 7.1-14
PARTSWITCH . . . . . . . . . . . . . . . 7.2-5
PFEFORMAT . . . . . . . . . . . . . . . 7.10-8
%PI . . . . . . . . . . . . . . . . . . 6-1
PIECE . . . . . . . . . . . . . . . . . 7.2-5
POWERDISP . . . . . . . . . . . . . . . 7.10-8
PRED . . . . . . . . . . . . . . . . . . 7.1-1,2
PREDERROR . . . . . . . . . . . . . . . 7.13-1, 12-1
PSEXPAND . . . . . . . . . . . . . . . . 7.6-4
RATDENOMDIVIDE . . . . . . . . . . . . . 7.1-4
RATEPSILON . . . . . . . . . . . . . . . 7.3-1
RATEXPAND . . . . . . . . . . . . . . . 7.1-4
RATPRINT . . . . . . . . . . . . . . . . 7.6-1
RATSIMP . . . . . . . . . . . . . . . . 7.1-1
RATSIMPEXPONS . . . . . . . . . . . . . 7.1-15
RETAINNUM . . . . . . . . . . . . . . . 10-1,2
RULES . . . . . . . . . . . . . . . . . 7.10-7
SAVEFACTORS . . . . . . . . . . . . . . 7.1-9
SCALARMATRIX . . . . . . . . . . . . . . 7.4-5
SCOPEHEIGHT . . . . . . . . . . . . . . 7.10-9, 11-1
SIMP . . . . . . . . . . . . . . . . . . 4-3
SIMPSUM . . . . . . . . . . . . . . . . 7.1-13
SOLVEFACTORS . . . . . . . . . . . . . . 7.3-2
SOLVERADCAN . . . . . . . . . . . . . . 7.3-2
STORENUM . . . . . . . . . . . . . . . . 10-3
TAYLORDEPTH . . . . . . . . . . . . . . 7.5-4
TIME . . . . . . . . . . . . . . . . . . 7.10-7
TRIGEXPAND . . . . . . . . . . . . . . . 7.1-16, 7.5-7
TRIGSIGN . . . . . . . . . . . . . . . . 7.1-15
TRUE . . . . . . . . . . . . . . . . . . 6-1
UNAME . . . . . . . . . . . . . . . . . 10-3, 11-1
VALUES . . . . . . . . . . . . . . . . . 3-2, 7.10-7
ZEROBERN . . . . . . . . . . . . . . . . 6-2
β
Bibliography and References
1. A.C.M. Proceedings of the Second Symposium on Symbolic and
Algebraic Manipulation, Los Angeles, Calif., March, 1971. +
2. A.C.M. Communications - August 1971 Vol. 14 No. 8 +
3. A.C.M. Journal - October 1971 Vol. 18 No. 4 +
4. Berlekamp, E. R. "Factoring Polynomials Over Large Finite
Fields" - Mathematics of Computation Vol. 24 No. 111 July
1970
5. Brown, W. S. - "On Euclid's Algorithm and the Computation of
Polynomial Greatest Common Divisors" in [3].
6. Collins, G. E. - "The Calculation of Multivariate Polynomial
Resultants" in [3].
7. Dowson, M. "How to Get on the System" - A. I. Memo 215 April
1971 *
8. Eastlake, D., et. al. "ITS 1.5 Reference Manual" - A.I. Memo
161A July 1969 *
9. Fateman, R. J. "The User-Level Semantic Matching Capability in
MACSYMA" - in [1].
10. --- "On the Computation of Powers of Sparse Polynomials" *
11. --- "Rationally Simplifying Non-Rational Expressions" - SIGSAM
Bulletin July 1972 No. 23
12. --- "Essays in Algebraic Simplification" - Ph.D. Thesis - MAC
TR-95 April 1972 **
13. --- and Moses, J. "Canonical Simplification of First Order
Exponential Expressions" - in preparation.
14. Knuth, D. "Seminumerical Algorithms" in "The Art of Computer
Programming" Vol. 2 Addison-Wesley Publishers 1969
15. Martin, W. A. "Computer Input/Output of Mathematical
Expressions" in [1].
16. --- "Determining the Equivalence of Algebraic Expressions by
Hash Coding" in [1,3].
17. --- "Symbolic Mathematical Laboratory" - Ph.D. Thesis - MAC
TR-36 January 1967 AD-657-283 ***
18. --- and Fateman, R. J. - "The MACSYMA System" in [1].
19. McCarthy, J. et. al. "LISP 1.5 Programmers' Manual" - MIT
Press
20. Moses, J. "Algebraic Simplification - A Guide for the
Perplexed" - in [1,2].
21. --- "Symbolic Integration - The Stormy Decade" - in [1,2].
22. --- "Towards a General Theory of Special Functions" -
Communications of the Assocation for Computing Machinery
July 1972 Vol. 15 No. 7 +
23. --- "Symbolic Integration" - Ph.D. Thesis - MAC TR-47
December 1967 AD-662-666 ***
24. --- "MACSYMA Primer" *
25. Osman, E. "DDT Reference Manual" - A.I. Memo 147A Sept 1971 *
26. Wang, P. "Automatic Computation of Limits" - in [1].
27. --- "Application of MACSYMA to an Asymptotic Expansion
Problem" - Proceedings of the ACM Annual Conference August
1972 Vol. 2 +
28. --- "Evaluation of Definite Integrals by Symbolic
Manipulation" - Ph.D. Thesis - MAC TR-92 October 1971 **
29. --- and Rothschild, L. "Factoring Multivariate Polynomials
over the Integers" - Submitted to Mathematics of
Computation. *
30. White, John L. "An Interim LISP Users' Guide" - A. I. Memo
190 March 1970 *
31. Yun, D.Y. and Moses, J. "The EZ GCD Algorithm" - Procedings
of the ACM convention August 1973. +
Where to Obtain Publications
* Available from Mathlab Group Project MAC - MIT Room 831
545 Technology Square
Cambridge, Mass. 02139
** Available for a charge from Information Services Publications
Distribution Room 417A
545 Technology Square
Cambridge, Mass. 02139
*** Available for a charge from National Technical Information
Service (NTIS) Operations Division
Springfield, Va. 22151
(include AD number given with reference)
+ Available from The Association for Computing Machinery
1133 Avenue of the Americas
New York, N.Y. 10036
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ